2012-04-06 19 views

回答

24

如果從支持編碼類繼承,所以一般adviseable在encodeWithCoder:方法使用[super encodeWithCoder:],儘可能[super initWithCoder:]initWithCoder:方法中使用。

文檔:NSCoding Protocol Reference

參考:http://www.cocoadev.com/index.pl?NSCoder

如果類從符合 (NSObject的不符合),那麼你應該包括一個類繼承的[encodeWithCoder:]方法。

// <NSCoding> protocol methods 

-(void)encodeWithCoder:(NSCoder*)coder 
{ 
    [super encodeWithCoder:coder]; 
    /* 
    [coder encodeObject: theNSStringInstanceVariable]; 
    [coder encodeObject: theNSDictionaryInstanceVariable]; 
    [coder encodeValueOfObjCType:@encode(BOOL) at:&theBooleanInstanceVariable]; 
    [coder encodeValueOfObjCType:@encode(float) at:&theFloatInstanceVariable]; 
    */ 
} 
+2

謝謝了很多:) – XaitormanX 2012-04-06 08:53:26

+0

@XaitormanX歡迎你,我的朋友! :-) – 2012-04-06 08:54:33

相關問題