Re: NSMutableDictionary or Custom Object when adding properties?

2013-05-22 Thread Christ Levesque
Howdy, It's very easy to do using runtime. I have a framework for doing dynamic creation at runtime. Also, It's easy to get O-C based class elements such as properties, ivars, protocols. methods using runtime. You can take a look at this. https://gist.github.com/Ch0c0late/5575679 It

Re: NSMutableDictionary or Custom Object when adding properties?

2013-05-17 Thread Ken Thomases
On May 17, 2013, at 12:43 AM, Trygve Inda wrote: I need to keep a small (few thousand) record database of sorts. Each record has some pre-detertermined fields, but the user can add there own fields to to a limited extent. … This will be simple objects in an NSMutableArray. I can use an

Re: NSMutableDictionary or Custom Object when adding properties?

2013-05-17 Thread Trygve Inda
On May 17, 2013, at 12:43 AM, Trygve Inda wrote: I need to keep a small (few thousand) record database of sorts. Each record has some pre-detertermined fields, but the user can add there own fields to to a limited extent. … This will be simple objects in an NSMutableArray. I can use an

Re: NSMutableDictionary or Custom Object when adding properties?

2013-05-17 Thread Ken Thomases
On May 17, 2013, at 1:18 AM, Trygve Inda wrote: On May 17, 2013, at 12:43 AM, Trygve Inda wrote: The trouble comes in the fact that I need to be able to add properties at runtime. For the dictionary option, it is easy - just make sure the key names don't collide and I can add more keys to

Re: NSMutableDictionary or Custom Object when adding properties?

2013-05-17 Thread Graham Cox
On 17/05/2013, at 3:43 PM, Trygve Inda cocoa...@xericdesign.com wrote: But for the objects I don't see a nice way to do this There is setValue:forUndefinedKey: and then each object could keep a local dictionary of these defined at runtime keys. There are low-level runtime methods that

Re: NSMutableDictionary or Custom Object when adding properties?

2013-05-17 Thread Trygve Inda
On May 17, 2013, at 1:18 AM, Trygve Inda wrote: On May 17, 2013, at 12:43 AM, Trygve Inda wrote: The trouble comes in the fact that I need to be able to add properties at runtime. For the dictionary option, it is easy - just make sure the key names don't collide and I can add more keys to

Re: NSMutableDictionary or Custom Object when adding properties?

2013-05-17 Thread Sandor Szatmari
If you go the dictionary route a simple category on NSDictionary would allow you to compute dynamic properties such as area = length * width. Sandor Szatmari On May 17, 2013, at 1:43, Trygve Inda cocoa...@xericdesign.com wrote: I need to keep a small (few thousand) record database of sorts.

Re: NSMutableDictionary or Custom Object when adding properties?

2013-05-17 Thread Thomas Davie
Alternatively, a dictionary mapping keys onto blocks of type (void(^)(void)), which each compute their result. That, combined with typedef void(^voidBlock)(void); voidBlock constant(id r) { return [^{return r;} copy]; } would give you a dictionary that can store both constants and computed

Re: NSMutableDictionary or Custom Object when adding properties?

2013-05-17 Thread Trygve Inda
On May 16, 2013, at 11:41 PM, Graham Cox graham@bigpond.com wrote: There is setValue:forUndefinedKey: and then each object could keep a local dictionary of these defined at runtime keys. There are low-level runtime methods that allow you to add properties at runtime. I'm not sure

Re: NSMutableDictionary or Custom Object when adding properties?

2013-05-17 Thread Jens Alfke
On May 17, 2013, at 1:43 PM, Trygve Inda cocoa...@xericdesign.com wrote: How is this really any different than using setValue:forUndefinedKey? If you’re just going to access properties through KVC it’s not. Maybe that’s all the OP needs? What it gives you is actual ObjC-level properties that

NSMutableDictionary or Custom Object when adding properties?

2013-05-16 Thread Trygve Inda
I need to keep a small (few thousand) record database of sorts. Each record has some pre-detertermined fields, but the user can add there own fields to to a limited extent. It is a pretty light use so CoreData isn't what I really want, plus migrating to future structures is an issue with CoreData.