I am trying to add an object to an NSMutableDictionary
using the setObject:forKey:
function,
but for whatever reason, when I run my app in the iPhone simulator and try to perform the action, the code stops at the line were I am trying to add the object to the dictionary. The line where the program gets stuck is as follows:
[_dict setObject:_tf.text forKey:[NSString stringWithFormat:@"keywords_%i", [_keywordsArray count]]];
Where '_dict' is an NSMutableDictionary
object, '_tf' is a UITextField
, and '_keywordsArray' is an NSMutableArray
.
Overall, I am using the objects (aka keys) from my dictionary to populate an NSMutableArray
, which is used to fill a UIPickerView
. Initially, I load the dictionary from a .plist file, and I can tell the NSMutableDictionary
and the NSMutableArray
are both getting populated/filled correctly, and that the UIPickerView
is working fine, the only part that isn't working is adding objects to the NSMutableDictionary
(when the user presses a button in the UI). Also, I did get an error once that said that the NSMutableArray
had a count of 0 (zero), when clearly it didn't.
Any help/suggestions would be greatly appreciated!