nsdictionary as constant

Discussion in 'iOS Programming' started by johnmerlino, May 22, 2012.

  1. johnmerlino macrumors member

    Joined:
    Oct 22, 2011
    #1
    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
    
     
  2. johnmerlino thread starter macrumors member

    Joined:
    Oct 22, 2011
    #3
  3. johnmerlino thread starter macrumors member

    Joined:
    Oct 22, 2011
    #4
    Is there a way I can pass an NSStringer rather than an integer:

    Code:
    enum control_str {disarm = @"disarm",  arm = @"arm" };
    
     
  4. robvas macrumors 68020

    Joined:
    Mar 29, 2009
    Location:
    USA
    #5
    In Ruby you are using Arrays and Hashes. In Objective-C those are NSArray and NSDictionary
     

Share This Page