iPhone开发目标C:NSArray访问单个元素

iPhone开发目标C:NSArray访问单个元素,iphone,nsarray,kumulos,Iphone,Nsarray,Kumulos,我正在使用Kumulos为我的iPhone应用程序存储一个数据库,除了select方法外,其他一切都运行良好 在数据库上执行select时调用此方法: -(void) kumulosAPI:(Kumulos*)kumulos apiOperation:(KSAPIOperation*)operation crissDidCompleteWithResult:(NSArray*)theResults; { NSString *poche = [theResults objectAtInde

我正在使用Kumulos为我的iPhone应用程序存储一个数据库,除了select方法外,其他一切都运行良好

在数据库上执行select时调用此方法:

-(void) kumulosAPI:(Kumulos*)kumulos apiOperation:(KSAPIOperation*)operation crissDidCompleteWithResult:(NSArray*)theResults;
{
   NSString *poche =  [theResults objectAtIndex:0];
   NSLog("%@",poche);
}
如您所见,该方法返回NSArray,这是我从日志控制台得到的结果

2011-03-23 00:59:18.844 GpsProject[8708:207] {
    location = "Rue de Lisieux";
    name = tayeul;
    timeCreated = "2011-03-22 17:31:32 +0000";
    timeUpdated = "1999-11-30 00:00:00 +0000";
    userID = 10;
}
但是我不希望这些数据在一个字符串中,我希望它们分开。
例如,我需要“位置”。。。我找不到它。

数组中的对象可能是字典。尝试:

NSString *poche =  [[theResults objectAtIndex:0] objectForKey:@"location"];
NSLog("%@",poche);

我对kumulos一无所知,所以上面只是猜测。

数组中的对象可能是字典。尝试:

NSString *poche =  [[theResults objectAtIndex:0] objectForKey:@"location"];
NSLog("%@",poche);

我对kumulos一无所知,所以上面只是一个猜测。

结果数组看起来更像一个NSDictionary数组。因此,您可以使用字典的键值轻松访问各个元素。 例如,如果您想访问位置,可以通过

 NSString *location = [[theResults objectAtIndex:0] objectForKey:@"location"];

希望这有帮助。

结果数组看起来更像NSDictionary的数组。因此,您可以使用字典的键值轻松访问各个元素。 例如,如果您想访问位置,可以通过

 NSString *location = [[theResults objectAtIndex:0] objectForKey:@"location"];
希望这有帮助