Doesn't seem weird to me, I do it all the time. One advantage of using a custom class over a dictionary is that the compiler knows what's expected of it, while a dictionary is just a black box.
On Jun 17, 2014, at 3:21 PM, Trygve Inda wrote: > I need to store a large collection of settings (not application preferences, > but parameters describing how complex data is to be displayed) and am > looking for pros/cons as to the best way. > > At the top I have a class called MySettings. Within this I need to have > groups of related settings. They can either be NSMutableDictionary or a > custom class containing properties, but no methods. > > @interface MySettings : NSObject > { > MySettingsAppearance* appearance; // size, graphic style etc. > MySettingsColors* colors; // colors for different elements > MySettingsLocations* locations; // array of data > > ... About 8 more like these ... > } > > > In this way I could do something like: > > [[settings appearance] width] > [[settings colors] centerline] > [[[settings locations] allLocations] objectAtIndex:i] > > Alternatively I could do: > > @interface MySettings : NSObject > { > NSMutableDictionary* appearance; // size, graphic style etc. > NSMutableDictionary* colors; // colors for different elements > NSMutableDictionary* locations; // array of data > > ... About 8 more like these ... > } > > > [[settings appearance] objectForKey:kSettingsAppearanceWidth] > [[settings colors] objectForKey:kSettingsColorCenterline] > [[[settings locations] objectForKey:kSettingsLocationsAll] objectAtIndex:i] > > > All the data in the dictionaries (or custom property-only classes) will be > standard types: NSNumber, NSData, NSString, NSColor (which will have to be > archived to convert it to NSData for saving). > > Thoughts on the pros and cons of both methods? > > It feels weird to create a class that has zero methods (other than > getters/setters). > > Thanks, > > Trygve > > > > _______________________________________________ > > 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: > https://urldefense.proofpoint.com/v1/url?u=https://lists.apple.com/mailman/options/cocoa-dev/lrucker%2540vmware.com&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=yJFJhaNnTZDfFSSz1U9TSNMmxGyib3KjZGuKfIhHLxA%3D%0A&m=0WilBCnsowzp%2FdQ4L4RWeeHju%2FtkFlg998wjBlKNrzQ%3D%0A&s=35ee4fc7f8e133c7ca5f5c74da398a3ba1d7eee98ca41bcaadc1387cd9929aee > > This email sent to lruc...@vmware.com _______________________________________________ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com