大家好,我創建了一個json請求:
for (int i=0; i<= [urls count]-1; i++) {
self.items=[[NSMutableDictionary alloc] init];
[self.items setObject:[names objectAtIndex:i] forKey:@"results"];
[self.items setObject:[urls objectAtIndex:i] forKey:@"URL"];
[self.list addObject:_soccerList];
}
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:_list
options:0
error:&error];
self.results=[NSJSONSerialization
JSONObjectWithData:jsonData
options:0
error:&error];
但是我需要添加這個標題到json請求中,其中添加條目計數。不知道如何實現?
{
"resultCount":50,
"results": [
/// json content
]
}
for循環的adding _soccerList
,在這行之前加下面的代碼:
NSDictionary *dic=[[NSDictionary alloc] initWithObjectsAndKeys:[self.items count],@"resultCount",nil];
[self.list addObject:dic];