大家好我在nslog返回以下内容时有字典值:
NSDictionary * dict = [NSJSONSerialization JSONObjectWithData:data1 选项:0错误:nil]; DLog(@“RESPONSE ======%@”,dict);
{
errors = (
{
"@msg" = "already exists";
"@title" = "title";
}
); }
如何从中提取msg密钥数据?
答案 0 :(得分:3)
NSArray *array = dict[@"errors"];
NSDictionary *error1 = array[0];
NSString *msg = error1[@"@msg"];
NSString *msg
现在包含already exists
。
答案 1 :(得分:0)
您可以像这样提取它:
NSString *msg = [myDictionary objectForKey:@"@msg"];
并删除如下:
[myDictionary removeObjectForKey:@"@msg"];
答案 2 :(得分:0)
NSDictionary dic2 = [dict objectforKey:@"errors"];
NSString* msg = [dict2 objectForKey:@"@msg"];