Re: Referencing known values in core data

2008-08-13 Thread I. Savant

On Aug 13, 2008, at 5:34 AM, Andrew Zahra wrote:

I am experimenting with core data. Binding fields such as text  
fields works
fine. But now I have a pop up menu I want to bind to a set of known  
values.
I have a "Task" Entity with a "frequency" field. The frequency field  
is a
set of known values, such as hourly, daily etc, so I have not put  
this in my
model as a separate entity. What is the correct way to handle this  
situation
so the value of the popup menu gets saved and loaded from the core  
data

store?


  One way to do this (the way I usually do it) is to:

1 - Define somewhere a lookup list based on numbers.
(example: [NSNumber numberWithInt:1] represents "hourly", 2 is  
"daily" ...)
2 - In your entity, specify your 'frequency' attribute as one of the  
integer types.
3 - For each popup that uses this list, create an item for each word  
(hourly, daily, ...) by hand, setting each item's tag to the number  
that represents that item.

(example: set the "hourly" item's tag to "1")
4 - Bind the popup's "selectedTag" to your Task entity's 'frequency'  
attribute via some controller.


  That's it. You may wonder why I don't just suggest using the  
'selectedIndex' binding. Simple: you may some day want to insert  
"weekly" between "daily" and "monthly". That would cause problems with  
existing user data since the indices would change. Via the tag method,  
you can reorder / insert menu items at will.


--
I.S.


___

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 [EMAIL PROTECTED]


Referencing known values in core data

2008-08-13 Thread Andrew Zahra
I am experimenting with core data. Binding fields such as text fields works
fine. But now I have a pop up menu I want to bind to a set of known values.
I have a "Task" Entity with a "frequency" field. The frequency field is a
set of known values, such as hourly, daily etc, so I have not put this in my
model as a separate entity. What is the correct way to handle this situation
so the value of the popup menu gets saved and loaded from the core data
store?

thanks,
Andrew
___

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 [EMAIL PROTECTED]