【发布时间】:2012-06-02 05:46:34
【问题描述】:
-(void)getItems
{
NSString *root = URL
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@/phpfile", root]];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON)
{
[self.object removeAllObjects];
id results = [JSON valueForKeyPath:@"ids"];
[results enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop)
{
[self.object addObject:[NSString stringWithFormat:@"%@",[obj valueForKey:@"item1"]]];
[self.object2 addObject:[NSString stringWithFormat:@"%@",[obj valueForKey:@"item2"]]];
-(void)DidLoad
{
//initializing arrays to hold data
//Initiate arrays that hold data
object1 = [[NSMutableArray alloc] init];
object2 = [[NSMutableArray alloc] init];
[getItems];
//Why do I get empty arrays here e.g object 1 and 2 are returning empty ?
【问题讨论】:
-
请在此处发帖时更清楚地说明您的问题。
-
@MichaelDautermann,这是相同的代码,不同的问题。我发布了两次,因为我得到了部分答案.. 谢谢
-
@ShaggyFrog .. 感谢您的快速回复.. 这些可变数组 objec1 和 object2 具有对象(带有对象的 URL 字符串)对象 1 具有照片的名称,对象 2 具有相片。我想获取这些详细信息,例如照片的名称。但是这里的 NSMutable 数组返回的是空的。这清楚吗?
标签: iphone uitableview nsmutablearray