Hellos在这里有点受阻我想要一个有限的弦乐 例如:只有前两个值db_id 1和2
{
date = "12/01/2012";
"db_id" = 1;
},
{
date = "10/01/2012";
"db_id" = 2;
},
{
date = "09/12/2015";
"db_id" = 3;
},
{
date = "10/12/2015";
"db_id" = 4;
},
NSString *requestString = @"url";
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:requestString]];
NSError *error;
NSDictionary *JSON = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
NSArray *Array = [JSON valueForKey:@"moods"];
NSLog(@"%@",Array);
for (NSMutableArray *result in Array)
{
NSDictionary* Date = [result valueForKey:@"db_id"];
NSLog(@"%@",Date );
}
这是我的控制台在这种情况下我有10个字符串,但我只对前5个感兴趣
2015-12-17 10:34:21.978 App[5673:1609864] 1
2015-12-17 10:34:21.978 App[5673:1609864] 2
2015-12-17 10:34:21.978 App[5673:1609864] 3
2015-12-17 10:34:21.978 App[5673:1609864] 4
2015-12-17 10:34:21.979 App[5673:1609864] 5
2015-12-17 10:34:21.979 App[5673:1609864] 6
2015-12-17 10:34:21.979 App[5673:1609864] 7
2015-12-17 10:34:21.979 App[5673:1609864] 8
2015-12-17 10:34:21.980 App[5673:1609864] 9
2015-12-17 10:34:21.980 App[5673:1609864] 10
答案 0 :(得分:0)
NSMutableArray *result;
for (int i = 0 ; i < Array.count ; i++)
{
NSDictionary* Date = [result valueForKey:@"db_id"];
NSLog(@"%@",Date );
}