Skip navigation.
 
mlRe: Struct, Object, or Dictionary?
FROM : lbland
DATE : Tue Jul 01 20:45:49 2008

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_removed>)
>
> 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/<email_removed>
>
> This email sent to <email_removed>

Related mailsAuthorDate
mlStruct, Object, or Dictionary? Bridger Maxwell Jul 1, 19:53
mlRe: Struct, Object, or Dictionary? James Bucanek Jul 1, 20:18
mlRe: Struct, Object, or Dictionary? Keary Suska Jul 1, 20:30
mlRe: Struct, Object, or Dictionary? Andy Lee Jul 1, 20:36
mlRe: Struct, Object, or Dictionary? Bridger Maxwell Jul 1, 20:41
mlRe: Struct, Object, or Dictionary? lbland Jul 1, 20:45
mlRe: Struct, Object, or Dictionary? Andy Lee Jul 2, 21:42
mlRe: Struct, Object, or Dictionary? mmalc Crawford Jul 3, 02:33