我正在使用 Facebook api 来获取用户的朋友姓名、UID 和生日。我遇到的问题是,一旦我得到结果,我如何获得这些值。意思是,我想获取每个返回值的用户名、生日?
这段代码在这里一直为我崩溃
//set query
NSString *query = @"SELECT uid, name, birthday_date FROM user WHERE uid IN " @"(SELECT uid2 FROM friend WHERE uid1 = me() LIMIT 25)";
// Set up the query parameter
NSDictionary *queryParam = [NSDictionary dictionaryWithObjectsAndKeys:query, @"q", nil];
[FBRequestConnection startWithGraphPath:@"/fql"
parameters:queryParam
HTTPMethod:@"GET"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error) {
if (error) {
NSLog(@"Error: %@", [error localizedDescription]);
}
else {
NSLog(@"Result: %@", result);
NSArray *friendInfo = (NSArray *) [result objectForKey:@"data"];
NSArray *arryData3 = [[NSArray alloc] initWithArray:friendInfo];
NSLog(@"[friendInfo count]: %d ... [arryData3 count]: %d ...",[friendInfo count],[arryData3 count]);
for (int i=0; i<[arryData3 count]; i++) {
NSArray *bdayArray = [[NSArray alloc] initWithArray:[arryData3 objectAtIndex:i]];
//CODE CRASH HERE!!!!
NSString *bdayStr = [bdayArray objectAtIndex:0];
NSString *nameStr = [bdayArray objectAtIndex:1];
}
}
}];
这就是我的崩溃日志的样子
data(
{
"birthday_date" = "01/06";
name = "John Doe";
uid = 555555;
},
{
"birthday_date" = "09/01/1984";
name = "Mrs. Smith";
uid = 4444444;
},
)
[friendInfo count]: 2 ... [arryData3 count]: 2 ...
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSArray initWithArray:range:copyItems:]: array argument is not an NSArray'
*** First throw call stack:
(0x168f052 0x1cabd0a 0x167fe0b 0x15e8170 0x16ca2 0x27c03 0x26c7e 0x2444e 0x2927e 0x296e7 0xfc1a59 0xfbfe94 0xfc0eb7 0xfbfe4f 0xfbffd5 0xf04f6a 0x3964bbd 0x3a315ea 0x395b298 0x3a3116b 0x395b137 0x166397f 0x15c6b73 0x15c6454 0x15c5db4 0x15c5ccb 0x3bd1879 0x3bd193e 0x5cca9b 0x2038 0x1f95)