我正在为iOS6编写一个Facebook解析器。昨天,我只用解析器做了一个测试项目。这样做效果很好。当我想在更大的项目中实现解析器(使用完全相同的方法代码)时,会给出一个"Parse Error: Expected ]“。设置了Social和Accounts的导入。这是给出错误的那一行:
SLRequest *retrieveWall = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodGET URL:newsFeed parameters:nil];下面是完整的方法:
-(void)fetchFacebookFrom:(NSString*)userID withAppKey:(NSString*)appKey
{
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *accountType = [accountStore
accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
NSDictionary *options = @{
@"ACFacebookAppIdKey" : appKey,
@"ACFacebookPermissionsKey" : @[@"email"],
@"ACFacebookAudienceKey" : ACFacebookAudienceEveryone
};
[accountStore requestAccessToAccountsWithType:accountType
options:options completion:^(BOOL granted, NSError *error) {
if(granted)
{
NSArray *arrayOfAccounts = [accountStore
accountsWithAccountType:accountType];
if ([arrayOfAccounts count] > 0)
{
ACAccount *facebookAccount = [arrayOfAccounts lastObject];
NSURL *newsFeed = [NSURL URLWithString:@"https://graph.facebook.com/12345678901/feed"];
SLRequest *retrieveWall = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodGET URL:newsFeed parameters:nil];
retrieveWall.account = facebookAccount;
[retrieveWall performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error)
{
if (error)
{
NSLog(@"Error: %@", [error localizedDescription]);
}
else
{
// The output of the request is placed in the log.
NSDictionary *jsonResponse = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingAllowFragments error:nil];
NSArray *statuses = [jsonResponse objectForKey:@"data"];
}
}];
}
}
else
{
NSLog(@"Not granted");
}
}];
}该错误特别指向方法调用中的"URL“。
这个愚蠢的错误已经让我抓狂了3个小时。我重新启动了XCode,清理了项目,并重新启动了我的Mac。谁看到了这个错误?
编辑:似乎这个特定的代码不是问题所在。我还添加了核心数据,它有一些方法名中带有URL的函数。方法名中包含URL的每个函数现在都会给出一个解析错误,并指向"URL“。越来越接近问题,但仍然不在那里!
发布于 2013-01-14 15:55:28
我们在头文件中的某个地方定义了URL。移除它可以修复它。感谢您考虑解决方案!
https://stackoverflow.com/questions/14276293
复制相似问题