iOS nsdictionary as constant

johnmerlino

macrumors member
Original poster
Oct 22, 2011
81
0
In ruby, you can do this:

Code:
class Command
STATUS = {
    1   => {  :immobilizer  => "OFF"  },
    2   => {  :immobilizer  => "ON"   },
    3   => {  :siren        => "OFF"  },
    4   => {  :siren        => "ON"   },
  }
end
And then access like this:

Code:
Command::STATUS[1] // => {  :immobilizer  => "OFF"  }

I'm wondering how to do the same thing in objective-c.

thanks for response
 

johnmerlino

macrumors member
Original poster
Oct 22, 2011
81
0
Is there a way I can pass an NSStringer rather than an integer:

Code:
enum control_str {disarm = @"disarm",  arm = @"arm" };
 

robvas

macrumors 68040
Mar 29, 2009
3,010
479
USA
In Ruby you are using Arrays and Hashes. In Objective-C those are NSArray and NSDictionary
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.