navigating a plist

Discussion in 'iOS Programming' started by beesbane, Oct 22, 2010.

  1. beesbane macrumors newbie

    Joined:
    Oct 16, 2010
    #1
    Hi,

    I have loaded in a plist, and nothing is crashing. I need to direct a UILabel to change to the plist's value, but can't seem to link that part right.

    label.text = [valueForKey:mad:"value"];

    This is right, but how do I tell it which item number in the list this is from?
    beesbane is offline Reply With Quote
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    No, it's not right. You are trying to call an instance method but have not specified which instance to call it on (i.e. your message has no receiver).
     
  3. beesbane thread starter macrumors newbie

    Joined:
    Oct 16, 2010
    #3
    it is in a button action. I was just wondering if there was a way to call specifically in the plist:

    item 0
    title
    "value for title"

    how would that be written?
     
  4. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
  5. beesbane thread starter macrumors newbie

    Joined:
    Oct 16, 2010
    #5
    an Array and a String

    Code:
    
    - (id)initWithLibraryName:(NSString *)libraryName {
        if (self = [super init]) {
            libraryPlist = libraryName;
            libraryContent = [[NSArray alloc] initWithContentsOfFile:[[NSBundle mainBundle] 
                                                                      pathForResource:libraryPlist ofType:@"plist"]];
        }
        return self;
    }
    
    
    
     
  6. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #6
    valueForKey: is used with NSDictionary not NSArray.

    EDIT: It might help if we can see the structure of your plist as well.
     

Share This Page