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

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

问题描述

这将加载一个数组

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

什么是code,它会调用这个函数,这样的阵列可以加载?

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

推荐答案

initWith codeR:方法用于反序列化使用<一个href=\"http://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Protocols/NSCoding_Protocol/Reference/Reference.html\"相对=nofollow> NSCoding协议,例如通过<一个href=\"http://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSKeyedUnarchiver_Class/\"相对=nofollow> [NSKeyedUnarchiver unarchiveObjectWithFile:] 。有关详情请参阅<一个href=\"http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/Archiving/Archiving.html%23//apple_ref/doc/uid/10000047i\"相对=nofollow>档案和序列化编程指南,特别是<一个href=\"http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/Archiving/Articles/codingobjects.html%23//apple_ref/doc/uid/20000948-BCIHBJDE\"相对=nofollow>编码和解码对象部分。

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.

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

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