Learn Hw to set up scores in Xcode 4.2.1: Check out MAppDeveloping Apps
Remember to subscribe for 3 videos a week. Support email: miguedeveloper@hotmail.com
Source code:
View Controller.h
@interface ViewController : UIViewController{
}
-(IBAction)next:(id)sender;
@end
View Controller.m
#import "ViewController.h"
#import "playArena.h"
@implementation ViewController
-(IBAction)next:(id)sender{
playArena *second =[[playArena alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:second animated:YES];
}
@end
playArena.h
@interface playArena : UIViewController{
IBOutlet UILabel *score;
IBOutlet UITextField *actualscore;
IBOutlet UITextField *lastscore;
NSTimer *timer;
IBOutlet UIView *alert;
int Int;
}
-(void)countup;
-(IBAction)repeat;
-(IBAction)stop;
@end
playArena.m
#import "playArena.h"
@implementation playArena
-(void)countup {
Int += 1;
score.text = [NSString stringWithFormat:@"%i", Int];
actualscore.text = [NSString stringWithFormat:@"%i", Int];
}
-(void)viewDidLoad{
Int = 0;
timer = [NSTimer scheduledTimerWithTimeInterval:0.1
target:self selector:@selector(countup)userInfo:nil repeats:YES];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *loadstring = [defaults objectForKey:@"savedstring"];
[lastscore setText:loadstring];
[alert setHidden:YES];
}
-(IBAction)repeat {
NSString *savestring = actualscore.text;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:savestring forKey:@"savedstring"];
[defaults synchronize];
playArena *second =[[playArena alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:second animated:YES];
}
-(IBAction)stop{
[alert setHidden:NO];
[timer invalidate];
}
@end
On this page of the site you can watch the video online Xcode Tutorials; Setting Up a Score - MAppDeveloping with a duration of hours minute second in good quality, which was uploaded by the user MAppDeveloping 20 March 2012, share the link with friends and acquaintances, this video has already been watched 3,923 times on youtube and it was liked by 7 viewers. Enjoy your viewing!