2011-05-22 325 views
0

簡單test--爲什麼會導致「exc_bad_access」錯誤?

- (void)viewDidLoad 
{ 
[super viewDidLoad]; 

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

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

} 

它得到了一致的錯誤 「NSTimeInterval ......」

程序接收到的信號: 'EXC_BAD_ACCESS'

你能告訴我哪裏錯了?

回答

0

您在NSLog語句中使用字符串格式代碼而不是數字格式代碼。嘗試:

NSLog(@"between: %f",timeBetween); 
相關問題