本文介绍了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协议,例如通过 。有关详情,请参阅,特别是部分。

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什么时候调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-14 21:02