Re: [Pyobjc-dev] pickled Objective-C objects
Brought to you by:
ronaldoussoren
From: <bb...@ma...> - 2003-02-24 16:17:12
|
On Monday, Feb 24, 2003, at 04:48 US/Eastern, Just van Rossum wrote: >>> __init__/tp_init method. Calling an ObjC class will then still >>> result in that exception, while still properly supporting __new__. >>> >> Class clusters may be problematic here (in combination with pickling). >> If you create an NSArray you actually end up with a subclass of >> NSArray. This should be pickled as if it is an NSArray (Apple might >> replace the classes implementing NSArray by a completely different set >> of classes). > > Yes, it abviously need to support classForCoder. But I would expect > that > NSArray.alloc().initWithCoder() is the right thing, no? If so, aliasing > __new__ to alloc() is quite natural. While I can't find the reference in the documentation, I'm fairly certain you are not supposed to directly invoke -initWithCoder:. file:///Developer/Documentation/Cocoa/TasksAndConcepts/ ProgrammingTopics/Archiving/index.html#//apple_ref/doc/uid/10000047i Somewhere in there, an NSArchiver/NSUnarchiver must be used to recompose the archived object graph. That is, you would use NSUnarchiver's.. + unarchiveObjectWithData:fp12; + unarchiveObjectWithFile:fp12; ... methods to unarchive the data. This takes care of all of the potential referential cycles that may be present in the object graph (example: if an array contains the same object three times, it'll be decoded as one instance with three references / retains in the array). b.bum (Who hadn't been paying close enough attention to the conversation to know whether or not the above is 100% relevant). |