bardockyo
bardockyo

Reputation: 1435

store text from uitextfield to a dictionary key

Is there a way to get the text from a uitextfield and save that into a dictionary at a certain key? I've tried numerous combinations but they either fail or do not enter the text. Here is what I have now that is not working:

NSString *string = self.userName.text;
string = [registration objectForKey:@"Username"];

but it doesnt enter the information at all. Any ideas?

Upvotes: 0

Views: 852

Answers (1)

Extra Savoir-Faire
Extra Savoir-Faire

Reputation: 6036

Assuming you've instantiated an instance of NSMutableDictionary for registration:

[registration setObject:string forKey:@"Username"];

will put a value into the dictionary for a given key, and

string = [registration objectForKey:@"Username"];

will retrieve it.

Upvotes: 2

Related Questions