开发者

Why it cause an "exc_bad_access" error?

开发者 https://www.devze.com 2023-03-07 07:58 出处:网络
a simple test-- - (void)viewDidLoad { [super viewDidLoad]开发者_开发问答; NSDate *date1 = [NSDate date];

a simple test--

- (void)viewDidLoad
{
[super viewDidLoad]开发者_开发问答;

NSDate *date1 = [NSDate date];
NSDate *date2 = [NSDate dateWithTimeIntervalSinceNow:3];

NSTimeInterval timeBetween = [date1 timeIntervalSinceDate:date2];
NSLog(@"between: %@",timeBetween);    

}

It got an error in line "NSTimeInterval..."

program received signal: 'EXC_BAD_ACCESS'

Would you tell me where is wrong?


you're using a string format code instead of a number format code in your NSLog statement. try:

NSLog(@"between: %f",timeBetween);
0

精彩评论

暂无评论...
验证码 换一张
取 消