2012-04-06 32 views

Trả lời

24

Nếu bạn kế thừa từ một lớp học có hỗ trợ mã hóa, nó là thường adviseable để sử dụng trong phương pháp [super encodeWithCoder:]encodeWithCoder: của bạn, càng nhiều càng tốt [super initWithCoder:] được sử dụng trong phương pháp initWithCoder:.

Tài liệu:NSCoding Protocol Reference

tham khảo:http://www.cocoadev.com/index.pl?NSCoder

nếu lớp kế thừa từ một lớp mà phù hợp với (NSObject không phù hợp) thì bạn nên bao gồm các [encodeWithCoder:] phương pháp.

// <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

Cảm ơn bạn rất nhiều :) – XaitormanX

+0

@XaitormanX Xin chào, bạn của tôi! :-) –

Các vấn đề liên quan