0
可能重複:
Images in Uiscroll cell populated by mysql database空Nsmutable陣列iPhone
-(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,它是相同的代碼,不同的問題。我發佈了兩次,因爲我得到了部分答案..謝謝 – user1430825
@ShaggyFrog ..謝謝你的快速回應..這些可變數組objec1和object2有對象(帶對象的URL字符串)對象1有照片和對象的名稱2有照片的網址。我想獲得這些細節,例如照片的名稱。但是這裏的NSMutable數組返回空。這是清楚的嗎? – user1430825