Folks,

  I'm trying to make sure that I correctly understand the rules for manual 
memory management in Cocoa.  In particular, I'm curious as to the safety of 
sending an object a release message and then using that object later on in the 
same method.

Here's the method that I'm curious about:

- (IBAction)createEmployee:(id)sender
{   
    // Create the new Person object
    Person *p = [employeeController newObject];
    
    // Add it to the content array of 'employeeController'
    [employeeController addObject:p];
    [p release];
    
    // Re-sort in case the user has sorted a column
    [employeeController rearrangeObjects];
    
    // Get the sorted array
    NSArray *a = [employeeController arrangedObjects];
    
    // Find the object just added
    NSUInteger row = [a indexOfObjectIdenticalTo:p];
    NSLog(@"starting edit of %@ in row %ld", p, row);
    
 }

Is it dangerous to send the release message to p right after adding it to the 
array?  Should I put the release at the end of the method?

--jon

_______________________________________________

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