gpt4 book ai didi

ios - string 转换成数组 Ios ,通过 webservices 获取

转载 作者:行者123 更新时间:2023-11-29 02:33:42 26 4
gpt4 key购买 nike

在 ios 中,我正在使用 Xml Soap 解析这是我的回复

<InsertResponse xmlns="http://OrderMe.solyn.in/"><InsertResult>[{"Result":"Success","AccessToken":"f60da1f1-40d7-483d-880a-82348dc20934","AppUserId":"35"}]</InsertResult></InsertResponse>

然后我使用此代码获取响应

-(void)parser:(NSXMLParser *) parser foundCharacters:(NSString *)string {
if (elementFound) {
// NSLog(@"%@",soapResults);
[soapResults appendString: string];
if ([Type isEqualToString:@"InsertResponse"] ) {
//--- Retrieving text of an element that is found---
NSLog(@"%@",string);
NSString *str = [[NSString alloc]initWithData:string encoding:NSUTF8StringEncoding];
NSArray *allData = [str JSONValue];

//NSString *loginID=[NSString stringWithFormat:@"%@",string];
//NSLog(@"Login ID Returned from web service is : %@",loginID);
}
}
}

在此代码中 ** NSLog(@"%@",string);** 此字符串是打印

[{"Result":"Success","AccessToken":"f60da1f1-40d7-483d-880a-82348dc20934","AppUserId":"35"}]

所以我不知道如何在数组中转换这个字符串我在等待回应请分享您宝贵的知识问候,尼尚钱德瓦尼谢谢 。

最佳答案

您需要将此字符串解析为 JSON:

NSString *string = @"[{\"Result\":\"Success\",\"AccessToken\":\"f60da1f1-40d7-483d-880a-82348dc20934\",\"AppUserId\":\"35\"}]";
NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];

关于ios - string 转换成数组 Ios ,通过 webservices 获取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26608549/

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