initWithCoder什么时候调用? [英] When does initWithCoder get called?

查看:77
本文介绍了initWithCoder什么时候调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这将加载数组

- (id)initWithCoder:(NSCoder*) coder
{
    self = [super initWithCoder: coder];
    if (self) {
        myArray=[coder decodeObjectForKey:@"myArray"];
    }
    return self;
}

什么是将调用此函数的代码, ?

What is the code that will call this function so that the array can be loaded?

推荐答案

initWithCoder:方法用于反序列化href =http://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Protocols/NSCoding_Protocol/Reference/Reference.html =nofollow noreferrer> NSCoding协议,例如通过 [NSKeyedUnarchiver unarchiveObjectWithFile:] 。有关详情,请参阅归档和序列化编程指南,特别是编码和解码对象部分。

The initWithCoder: methods are used for deserializing using NSCoding protocol, e.g. via [NSKeyedUnarchiver unarchiveObjectWithFile:]. For details see the Archives and Serializations Programming Guide, especially the Encoding and Decoding Objects section.

这篇关于initWithCoder什么时候调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆