Re: Struct, Object, or Dictionary?
Re: Struct, Object, or Dictionary?
- Subject: Re: Struct, Object, or Dictionary?
- From: lbland <email@hidden>
- Date: Tue, 1 Jul 2008 14:45:49 -0400
hi-
If you have to bind your entities to anything then you might try a
Core Data representation.
If you have multiple entities and need to store in a list then a
dictionary or class would be best as NSArray, etc. takes ids and
there is no easy store for multiple structs, unless you role your own.
The Core Data would be New-Cocoa-Cool IMHO.
thanks!-
-lance
On Jul 1, 2008, at 1:53 PM, Bridger Maxwell wrote:
Hey,
I have been debating using one method over another for a while now,
and I
would like to know what the Cocoa way of doing things is. I need to
group a
set of data together to use as one entity. In one program I was
representing
a puzzle as four strings and a BOOL. My first thought would be to
represent
these as a struct. However, the strings within the struct would
have to be
memory managed, so I guess that would mean writing my own methods
to retain,
release, autorelease, etc. the struct. My second option in this
case is to
declare an object that would contain all of those data members as
ivars, and
the memory management would be taken care of. However, it doesn't
seem right
to make an object that only has data and no methods. My third
option would
be to store all of the data in dictionary pairs. This doesn't seem as
reliable as the last methods though, because there is no guarantee
that the
dictionary would contain all the necessary name/value pairs. What
is the
"correct" way to do this in Cocoa?
Thank You,
Bridger Maxwell
_______________________________________________
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
_______________________________________________
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