gpt4 book ai didi

iphone - 将NSString转换为以特定字符分隔的NSDictionary

转载 作者:行者123 更新时间:2023-12-01 17:23:18 25 4
gpt4 key购买 nike

我需要将此字符串“5?8?519223cef9cee4df999436c5e8f3e96a?EVAL_TIME?60?2013-03-21”转换为字典。以“?”分隔

字典就像

{
sometext1 = "5",
sometext2 = "8",
sometext3 = "519223cef9cee4df999436c5e8f3e96a",
sometext4 = "EVAL_TIME",
sometext5 = "60",
sometext6 = "2013-03-21"
}

谢谢 。

最佳答案

将字符串分解为较小的字符串并循环播放。
这是这样

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++]];
}

关于iphone - 将NSString转换为以特定字符分隔的NSDictionary,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16129433/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com