Muh*_*ari 1 iphone objective-c nsdictionary nsstring ios
我需要将这个"5?8?519223cef9cee4df999436c5e8f3e96a?EVAL_TIME?60?2013-03-21"字符串转换成字典.用"?"分隔
字典会有点像
{
sometext1 = "5",
sometext2 = "8",
sometext3 = "519223cef9cee4df999436c5e8f3e96a",
sometext4 = "EVAL_TIME",
sometext5 = "60",
sometext6 = "2013-03-21"
}
Run Code Online (Sandbox Code Playgroud)
谢谢 .
将字符串分解为较小的字符串并为它们循环.这就是方法
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++]];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14392 次 |
| 最近记录: |