开发者

Archive/ unarchive objects in iPhone OS 3.0 & 2.2.1

开发者 https://www.devze.com 2022-12-26 14:58 出处:网络
I am trying to archive, unarchive objects using NSKeyedArchiver, NSKeyedUnarchiver, NSCoding (initWithCoder, encodeWithCoder methods) in order to access the last view before the application was termin

I am trying to archive, unarchive objects using NSKeyedArchiver, NSKeyedUnarchiver, NSCoding (initWithCoder, encodeWithCoder methods) in order to access the last view before the application was terminated.

This works with OS 3.0 and above, but for OS 2.2.1, the objects are unarchived but a blank screen is displayed on application relaunch.

This is how I have been trying to initialize my view:

- (id)initWithCoder:(NSCoder *)decoder{
    self = [super init];
    if (self != nil)
    {
 开发者_如何学Python       //my code
    }
    return self;

}

I also tried using initWithNibName method as follows

- (id)initWithCoder:(NSCoder *)decoder{
    self = [super initWithNibName:@"myView" bundle:nil];
    if (self != nil)
    {
        //my code
    }
    return self;

}

But a black screen is displayed.

Can anyone please help?


Actually, you should call

self = [super initWithCoder:decoder];
0

精彩评论

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

关注公众号