Created
September 9, 2013 04:19
-
-
Save joseph-montanez/6491416 to your computer and use it in GitHub Desktop.
Accessing thenDate Crashes...
'NSInvalidArgumentException', reason: '-[__NSCFString timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x7659160'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
@interface ViewController : UIViewController | |
@property (nonatomic) NSDate* thenDate; | |
@property (nonatomic) NSDate* nowDate; | |
@property (retain, nonatomic) IBOutlet UILabel *theTimer; | |
@property (retain, nonatomic) IBOutlet UILabel *theLabel; | |
-(void) updateTimer:(id) sender; | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "ViewController.h" | |
@interface ViewController () | |
@end | |
@implementation ViewController | |
@synthesize theLabel; | |
@synthesize theTimer; | |
@synthesize thenDate; | |
@synthesize nowDate; | |
-(void)updateTimer:(id)sender{ | |
nowDate = [NSDate date]; | |
NSTimeInterval startTime = [nowDate timeIntervalSinceReferenceDate]; | |
NSTimeInterval endTime = [thenDate timeIntervalSinceReferenceDate]; | |
} | |
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
thenDate = [NSDate date]; | |
nowDate = [NSDate date]; | |
[NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(updateTimer:) userInfo:nil repeats:YES]; | |
theLabel.text = @"Time"; | |
} | |
- (void)didReceiveMemoryWarning | |
{ | |
[super didReceiveMemoryWarning]; | |
// Dispose of any resources that can be recreated. | |
} | |
- (void)dealloc { | |
[theLabel release]; | |
[theTimer release]; | |
[super dealloc]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment