0
가능한 중복 :
Images in Uiscroll cell populated by mysql database빈 Nsmutable 배열 아이폰
-(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 사진의 URL이 있습니다. 나는이 세부 사항, 예를 들면 사진의 이름을 얻고 싶었다. 하지만 여기에 NSMutable 배열이 반환됩니다.이 명확한가요? – user1430825