Re: ArrayController, CoreData & Bindings
Re: ArrayController, CoreData & Bindings
- Subject: Re: ArrayController, CoreData & Bindings
- From: mmalcolm crawford <email@hidden>
- Date: Mon, 8 May 2006 20:21:56 -0700
On May 8, 2006, at 6:29 PM, Bobby B wrote:
This is what I'm trying to do: Upon the first run of my app, it
checks to see if there are any entries in some of the tables, which
are bound from the array controller to their CoreData models.
[...]
int weatherCount = [[weatherArray
valueForKeyPath:@"arrangedObjects.@count"] intValue];
NSLog (@":%d", weatherCount);
if (weatherCount == 0) {
[weatherArray add:self];
[weatherArray setSelectionIndex:0];
[weatherArray setValue:@"Hot & Sunny"
forKeyPath:@"selection.weather"];
Don't do this.
If you want to set up default data, create the required instances
directly.
<http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/
Articles/cdCreateMOs.html>
<http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/
Articles/cdUsingMOs.html>
If you're using NSPersistentDocument, this is illustrated in the
tutorial.
If you're not, and if you don't have any other means of determining
whether this is the first run -- such as, for example, whether the
store file exists..., then execute a suitable fetch and check the
results.
mmalc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden