0

The following is my one of the items in my settings bundle. It is a simple linked list that allows users to choose a different note color for my application.

enter image description here

So far, I am retrieving the object through the key "noteColor." This will eventually allow me to determine which value was selected in my linked list.

NSString *path = @"/var/mobile/Library/Preferences/NCNotes.plist";
NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:path];

noteColor = [[dict objectForKey:@"noteColor"] intValue];

One thing I'm unsure about so far is if noteColor should be an integer or not. I'm assuming so, because I am using numbers for my values.

Assuming this is correct, I then try to switch the color of my note depending on the value that was selected (using cases). This doesn't seem to work.

switch (noteColor) {
    case 0:
        // Black
        noteView.textColor = [UIColor purpleColor];
        break;
    case 1:
        // Blue
        noteView.textColor = [UIColor purpleColor];
        break;

}

Any ideas of what I am doing wrong?

  • 1
    From what I see, `objectForKey:@"noteColor"` should return nil. You don't have a key named "noteColor". You have a key named "key" which value is "noteColor". – Larme Feb 09 '14 at 20:03
  • @Larme so I should use valueForKey? –  Feb 09 '14 at 20:14
  • Maybe this will help [How to use the value in PSLinkListCell in preference bundle?][1] [1]: http://stackoverflow.com/questions/15318528/how-to-use-the-value-in-pslinklistcell-in-preference-bundle – stilllife Feb 09 '14 at 20:25

1 Answers1

0

you won't be able to read it as noteColor using the method you show.. there is no key noteColor.
That plist you show is meant to be used by the setting app to GENERATE default you read later on.

also: noteColor is one-based according to above list

Daij-Djan
  • 49,552
  • 17
  • 113
  • 135