尝试
NSString *string = @"5?8?3519223cef9cee4df999436c5e8f3e96a?EVAL_TIME?60?2013-03-21";
NSArray *stringComponents = [string componentsSeparatedByString:@"?"];
//This is very risky, your code is at the mercy of the input string
NSArray *keys = @[@"cid",@"avid",@"sid",@"TLicense",@"LLicense",@"date"];
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
for (int idx = 0; idx<[stringComponents count]; idx++) {
NSString *value = stringComponents[idx];
NSString *key = keys[idx];
[dictionary setObject:value forKey:key];
}
编辑:更优化
NSString *string = @"5?8?3519223cef9cee4df999436c5e8f3e96a?EVAL_TIME?60?2013-03-21";
NSArray *stringComponents = [string componentsSeparatedByString:@"?"];
NSArray *keys = @[@"cid",@"avid",@"sid",@"TLicense",@"LLicense",@"date"];
NSMutableDictionary *dictionary = [NSMutableDictionary dictionaryWithObjects:stringComponents forKeys:keys];