• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSArrayController addObject or insertObject:atArrangedObjectIndex:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSArrayController addObject or insertObject:atArrangedObjectIndex:


  • Subject: Re: NSArrayController addObject or insertObject:atArrangedObjectIndex:
  • From: BareFeet <email@hidden>
  • Date: Tue, 22 Sep 2009 22:40:30 +1000

On 22/09/2009, at 5:18 PM, Dave Keck wrote:

It looks like dataRowsController is no longer a valid object by the
time -addObject:/-insertObject: is called on it.

Thanks for the reply Dave.

That doesn't seem to be the problem. dataRowsController is hooked up via Interface Builder to the NSArrayController. I know it's valid because the method in my code [dataRowsController selectionIndex] works, as does a test method [dataRowsController content].

I think I've found the problem though.

It seems that the addObject: or insertObject: method call on the controller actually calls the getter then the setter for the whole array. I had an NSLog in my getter that was actually causing the error:

- (void) setDataRows:(NSMutableArray *)newDataRows
{
	NSLog(@"setDataRows: count == %@", [newDataRows count]);
	[dataRows autorelease];
	dataRows = newDataRows;
	[dataRows retain];
}

Once I removed the NSLog line (or just the [newDataRows count] method), it works fine.

Two followup questions:

1. Why can't I use the array count in the NSlog like that?

2. Does addObject: and insertObject: actually just get the whole array, add the extra object, then write the whole array back to the instance variable? I thought it would be more efficient than that.

Thanks,
Tom
BareFeet

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSArrayController addObject or insertObject:atArrangedObjectIndex:
      • From: Graham Cox <email@hidden>
    • Re: NSArrayController addObject or insertObject:atArrangedObjectIndex:
      • From: Graham Cox <email@hidden>
References: 
 >NSArrayController addObject or insertObject:atArrangedObjectIndex: (From: BareFeet <email@hidden>)
 >Re: NSArrayController addObject or insertObject:atArrangedObjectIndex: (From: Dave Keck <email@hidden>)

  • Prev by Date: Re: Oh notification, where are you?
  • Next by Date: Re: NSArrayController addObject or insertObject:atArrangedObjectIndex:
  • Previous by thread: Re: NSArrayController addObject or insertObject:atArrangedObjectIndex:
  • Next by thread: Re: NSArrayController addObject or insertObject:atArrangedObjectIndex:
  • Index(es):
    • Date
    • Thread