NSArrayController addObject or insertObject:atArrangedObjectIndex:
NSArrayController addObject or insertObject:atArrangedObjectIndex:
- Subject: NSArrayController addObject or insertObject:atArrangedObjectIndex:
- From: BareFeet <email@hidden>
- Date: Tue, 22 Sep 2009 17:12:55 +1000
Hi all,
I have an NSArrayController and am trying to get an "add" button to
work, so that it inserts a new DataRow object at the current
selection, or at the end if no selection.
Here's my code:
- (IBAction) insertDataRow:(id)sender
{
DataRow* newDataRow = [[DataRow new] autorelease];
[newDataRow setTransactionPending:@"insert"]; // just a flag in the
DataRow object
NSUInteger controllerSelectionIndex = [dataRowsController
selectionIndex];
if (controllerSelectionIndex == NSNotFound)
{
[dataRowsController addObject:newDataRow];
}
else
{
[dataRowsController insertObject:newDataRow
atArrangedObjectIndex:controllerSelectionIndex];
}
}
When it gets to either the addObject or insertObject method, it
crashes with the error:
Program received signal: “EXC_BAD_ACCESS”
If I hook up an add button directly to the "insert" or "remove"
received action of the NSArrayController, it works fine. But I need to
run my own method so I can check and set other variables, such as the
setTransactionPending property shown above.
Can someone please tell me what I'm doing wrong?
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