Hi,
I'm trying to develop a Core Data. I'm new to Cocoa so I have a question regarding the 'normal' way of doing things.
I have instances of an entity that show up in a table using bindings (please correct me if my terminology is incorrect), and I want one column to simply show the line number.
In Hillegass, when 'adding' to a table, he specifies default values by subclassing NSArrayController. I did this like so:
This works fine on adding, but it obviously doesn't stay in sync if an item in the list is removed. How should this be kept in sync? Am I meant to somehow override a delete method and iterate through the arrangedObjects, resetting their number values?
Also, I saw people giving values to entity instances by subclasses NSManagedObject instead of NSArrayController. What are the benefits of each?
Thanks guys =)
Edit:
I think I can probably just unbind that particular column, set the dataSource outlet and return it normally.
I'm trying to develop a Core Data. I'm new to Cocoa so I have a question regarding the 'normal' way of doing things.
I have instances of an entity that show up in a table using bindings (please correct me if my terminology is incorrect), and I want one column to simply show the line number.
In Hillegass, when 'adding' to a table, he specifies default values by subclassing NSArrayController. I did this like so:
Code:
- (id)newObject
{
id newObj = [super newObject];
[newObj setValue:@"New Source" forKey:@"sourceFile"];
NSString *row = [NSString stringWithFormat:@"%d",[self.arrangedObjects count]+1];
[newObj setValue:row forKey:@"number"];
return newObj;
}
This works fine on adding, but it obviously doesn't stay in sync if an item in the list is removed. How should this be kept in sync? Am I meant to somehow override a delete method and iterate through the arrangedObjects, resetting their number values?
Also, I saw people giving values to entity instances by subclasses NSManagedObject instead of NSArrayController. What are the benefits of each?
Thanks guys =)
Edit:
I think I can probably just unbind that particular column, set the dataSource outlet and return it normally.