I want to compare two strings after reloading my App. (strold and strnew are declared global)
But if i call the string 'strold' in -applicationWillEnterForeground: i get the following error message:
0x011eca62 <+0022> push %edi
0x011eca63 <+0023> mov 0x8(%edx),%edi (BAD EXIT FOR THIS LINE)
- (void)applicationWillEnterForeground:(UIApplication *)application{
opendate = [NSDate date];
NSDateFormatter* formatter = [[[NSDateFormatter 开发者_运维问答alloc] init] autorelease];
[formatter setDateFormat:@"yyyy-MM-dd"];
strnew = [formatter stringFromDate:opendate];
NSLog(@"Active %@",strnew);
NSLog(@"Inctive %@",strold);
}
- (void)applicationWillResignActive:(UIApplication *)application{
closedate = [NSDate date];
NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] autorelease];
[formatter setDateFormat:@"yyyy-MM-dd"];
strold = [formatter stringFromDate:closedate];
}
I just want to check if a day changed actually. significanttime Method did not worked for me.
You will have to retain
strold
as it is autorelease
d.
strold = [[formatter stringFromDate:closedate] retain];
or
self.strold = [formatter stringFromDate:closedate];
if strold
is defined as a retained property.
精彩评论