2012-07-15 1 views
2

BITForursquare를 사용하여 근처 장소를 UITableView로 가져 오는 동안 정말 당황했습니다.NSCFArray (가능한 JSON)를 NSDictionary로 serialize하는 방법은 무엇입니까?

BZFoursquare : https://github.com/baztokyo/foursquare-ios-api

나는 requestDidFinishLoading 위임 방법 안에 내 Requestresult를 얻을. 이 메소드에서 request 객체는 여러 NSDictionaries를 포함하고 하나의 Dictionary는 request.response에 있습니다. 이 응답 사전에는 key = "venues"및 값으로 JSON 객체가있는 항목이 하나 있습니다. 나는 사전에이 값 개체를 넣을 때 유형이 사전하지만 NSCFArray 수없는 것 같다 다음 NSLog 라인이 나에게 다음과 같은 오류를 제공하기 때문에

#pragma mark BZFoursquareRequestDelegate 
- (void)requestDidFinishLoading:(BZFoursquareRequest *)request { 
    self.meta = request.meta; 
    self.notifications = request.notifications; 
    self.response = [request.response objectForKey:@"venues"]; 
    self.request = nil; 
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; 
    NSLog(@"%@",[self.response objectForKey:@"name"]); 
} 

나는이 가정

- [__ NSCFArray objectForKey : ] : 인스턴스로 전송 된 인식 할 수없는 선택기

이제는 모든 종류의 od 데이터 유형에서이 JSON을 얻지 못해 일부 시도가 혼란 스럽습니다. NSDictionary에 있습니다. 한 시도는있는 NSString에 값 개체를 넣고 사전에 그것을 얻을하지만 여전히 NSCFArray가 남아 있기 때문에 그 또한 실패 할

[NSJSONSerialization JSONObjectWithData:[responseString dataUsingEncoding:NSUTF8StringEncoding] options:0 error:&error]; 

사용하는 것이 었습니다. 누군가가 내가이 콘텐츠 내 UITabelview을 채울 수 있도록 내가있는 NSDictionary에

[request.response objectForKey:@"venues"] 

의 콘텐츠를 어떻게 말해 주시겠습니까?

편집 :

다음

사전 request.response의 값 부분에 무슨이다 :

(
    { 
    categories =   (
        { 
      icon =     { 
       name = ".png"; 
       prefix = "https://foursquare.com/img/categories/food/default_"; 
       sizes =      (
        32, 
        44, 
        64, 
        88, 
        256 
       ); 
      }; 
      id = 4bf58dd8d48988d10b941735; 
      name = "Falafel Restaurant"; 
      pluralName = "Falafel Restaurants"; 
      primary = 1; 
      shortName = Falafel; 
     } 
    ); 
    contact =   { 
    }; 
    hereNow =   { 
     count = 0; 
     groups =    (
     ); 
    }; 
    id = 4df3489dfa76abc3d86c4585; 
    likes =   { 
     count = 0; 
     groups =    (
     ); 
    }; 
    location =   { 
     cc = DE; 
     city = "Vinn"; 
     country = Germany; 
     distance = 92; 
     lat = "51.44985"; 
     lng = "16.648693"; 
     state = "Nordrhein-Westfalen"; 
    }; 
    name = "Yildiz D\U00f6ner"; 
    specials =   (
    ); 
    stats =   { 
     checkinsCount = 3; 
     tipCount = 0; 
     usersCount = 2; 
    }; 
    verified = 0; 
} 

는 그리고이 NSCFArray의 종류에서 보인다. 그리고이 사전에서 어떻게하면 JSON 값에 액세스 할 수 있습니까? 미안 오늘 내가 정말로 천천히라면. ..

+0

webservice에서 가져온 JSON을 기록해 주시겠습니까? –

답변

3

나는 당신이 그런 배열 인 것을 당연하다고 생각한다. 따라서 json을 비 직렬화 한 후에 반환 객체를 기록하여 사용자가 얻는 것을 확인하십시오. 거의 확실한 사전 배열입니다.

+1

네가 맞아! 그것은 배열이고 모든 항목은 사전입니다. – CaptnCrash

관련 문제