开发者

- (void)applicationWillResignActive and save string -->ERROR

开发者 https://www.devze.com 2023-03-13 21:27 出处:网络
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

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 autoreleased.

strold = [[formatter stringFromDate:closedate] retain];

or

self.strold = [formatter stringFromDate:closedate];

if strold is defined as a retained property.

0

精彩评论

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

关注公众号