does it matter which order objects are released at the end of a
method?  example:

-=-=-=-=-

- (void)applicationWillTerminate:(NSNotification *)notification
        {
        FourLines *fourLines = [[FourLines alloc] init];
        fourLines.field1 = field1.text;
        fourLines.field2 = field2.text;
        fourLines.field3 = field3.text;
        fourLines.field4 = field4.text;
        
        NSMutableData *data = [[NSMutableData alloc] init];
        NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc]
initForWritingWithMutableData:data];
        [archiver encodeObject:fourLines forKey:kDataKey];
        [archiver finishEncoding];
        [data writeToFile:[self dataFilePath] atomically:YES];
        
        [archiver release];
        [data release];
        [fourLines release];
        }

In the case above, and in general, no - most retains you'll have on other objects are for your own use, and if they keep a reference to anything themselves, they are responsible for retaining it on their own behalf. If, however, you have a retain on something on behalf of something else - e.g. you hand a struct to some function, which contains a pointer to an object that you have to retain on its behalf - then the order can matter, though for better or worse such scenarios often allow you to get away with it, whether coincidentally or luckily.

Wade
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to