> For example, is: > > NSMutableArray *anArray = [[NSMutableArray array] retain]; > > better than: > > NSMutableArray *anArray = [[NSMutableArray alloc] init];
I've been reamed, in the recent past, for expressing the opinion that the first was just as good as the second - apparently the answer depends on what platform you're on. The upshot was that apparently the iPhone developers like you to avoid the use of autorelease pools where possible. One hidden difference in the above is that in the first case you have (probably) populated the autorelease pool and in the other you (probably) haven't. I say probably because you can't know for sure in the majority of cases (its not explicitly documented). And there are aberrant cases like NSDateFormatter whose -init creates a bunch of autoreleased objects that you never see. (When worrying about memory usage, don't blindly trust documentation or heresay. Use Instruments!) Orthogonally, there are classes like NSPredicate where you don't have a choice - there are only convenience methods, no initPredicateWithFormat: _______________________________________________ Cocoa-dev mailing list ([email protected]) 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 [email protected]
