1
SBJSON 파서에 문제가 있습니다. json 파일을 제공하는 웹 사이트에서 정보를 얻으려고합니다. 그런 다음 문자열로 구문 분석 한 다음 사전에 추가합니다 (잘 작동합니다). 그러나 그 dict에서 마지막 요소 (이름)를 원할 때 그것은 단지 나에게 오류를 준다.NSString에서 NSString을 읽고 특정 항목 가져 오기
SBJsonParser *parser = [[SBJsonParser alloc] init];
self.videoId = videoId;
// Grab the contents from the url and save it in a string
NSString *content = [NSString stringWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://gdata.youtube.com/feeds/api/videos/%@?alt=json",videoId]] encoding:NSUTF8StringEncoding error:nil];
// Save the information from the string in a dict
NSDictionary *dict = [parser objectWithString:content error:nil];
NSArray *string = [[dict objectForKey:@"entry"] objectForKey:@"author"];
NSLog(@"%@", string);
여기에 출력입니다 : 여기 내 코드는 내가 이름 또는 URI를 얻는 방법
2012-10-10 11:11:47.731 quoteGen[13862:c07] (
{
name = {
"$t" = CommanderKrieger;
};
uri = {
"$t" = "http://gdata.youtube.com/feeds/api/users/CommanderKrieger";
};
}
)
?
감사합니다. :) – user1734282