• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Dictionaries or custom class containing no methods?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Dictionaries or custom class containing no methods?


  • Subject: Dictionaries or custom class containing no methods?
  • From: Trygve Inda <email@hidden>
  • Date: Tue, 17 Jun 2014 15:21:00 -0700
  • Thread-topic: Dictionaries or custom class containing no methods?

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 (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


  • Follow-Ups:
    • Re: Dictionaries or custom class containing no methods?
      • From: Quincey Morris <email@hidden>
    • Re: Dictionaries or custom class containing no methods?
      • From: Lee Ann Rucker <email@hidden>
  • Prev by Date: how can I get info from "vec_ycc_bgrx_convert" crash?
  • Next by Date: Re: Dictionaries or custom class containing no methods?
  • Previous by thread: how can I get info from "vec_ycc_bgrx_convert" crash?
  • Next by thread: Re: Dictionaries or custom class containing no methods?
  • Index(es):
    • Date
    • Thread