Convert NSString to NSDictionary separated by specific character
ios, iphone, nsdictionary, nsstring, objective-c
Solution
Break the string to smaller strings and loop for them. This is the way
NSArray *objects = [inputString componentsSeparatedByString:@"?"];
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
int i = 1;
for (NSString *str in objects)
{
[dict setObject:str forKey:[NSString stringWithFormat:@"sometext%d", i++]];
}
Problem
I need to convert this "5?8?519223cef9cee4df999436c5e8f3e96a?EVAL_TIME?60?2013-03-21" string into dictionary. Separated by "?" Dictionary would be some thing like ``` { sometext1 = "5", sometext2 = "8", sometext3 = "519223cef9cee4df999436c5e8f3e96a", sometext4 = "EVAL_TIME", sometext5 = "60", sometext6 = "2013-03-21" } ``` Thank you .