On Mar 28, 2010, at 10:42 AM, mmalc Crawford wrote:

>> That would be gut for the fact that my fields are released and set to nil 
>> whenever a new SELECT query is executed - however, I think I can do this by 
>> emptying the array when a new query is done and just counting the size of 
>> the array in my fetch method - thanks...
>> 
> Why not follow what someone else suggested earlier in the thread, and the 
> pattern that is recommended in the documentation, and use accessor methods. 
> As soon as you start sprinkling retains and releases throughout your code, 
> you're liable to make a mistake.
> <http://developer.apple.com/mac/library/documentation/cocoa/Conceptual/MemoryMgmt/Articles/mmPractical.html#//apple_ref/doc/uid/TP40004447>

Plus when you use accessor, you can put in a call to your NSLog( ) and see 
exactly whats going on...

- (void)setFields:(NSMutableArray *)newFields {
        NSLog( @"-setFields, old fields value: %p with new value %p", fields, 
newFields );
        [fields autorelease];
        fields = [newFields mutableCopy];
}

When calling setFields, you are then responsible for releasing the "newFields" 
NSMutableArray you created in your sample code, because [newFields mutableCopy] 
increments the ref counter.

_______________________________________________

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