【发布时间】:2015-11-20 07:14:05
【问题描述】:
我正在尝试为 iOS9.1 开发和操作扩展,它应该查询 Parse 以获取一些数据。
我已在扩展程序中添加、启用和测试 Parse,并且我成功地创建了测试对象并检查了当前用户。
我无法获取 Parse 查询方法中的代码 [查询 findObjectsInBackgroundWithBlock:^ 来执行。 LLDB 只是一直跳过它,所以我真的很茫然。
这段代码在容器应用程序中完美执行,所以我有点困惑。
- (void)viewDidLoad
{
[super viewDidLoad];
[Parse enableLocalDatastore];
[Parse enableDataSharingWithApplicationGroupIdentifier:@"group.com.app.slinky"
containingApplication:@"com.app.Slinky"];
[Parse setApplicationId:@"xxxxx"
clientKey:@"xxxxx"];
for (NSExtensionItem *item in self.extensionContext.inputItems) {
for (NSItemProvider *itemProvider in item.attachments) {
if ([itemProvider hasItemConformingToTypeIdentifier:(NSString *)kUTTypePropertyList]) {
[itemProvider loadItemForTypeIdentifier:(NSString *)kUTTypePropertyList options:nil completionHandler:^(NSDictionary *jsDict, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
NSDictionary *jsPreprocessingResults = jsDict[NSExtensionJavaScriptPreprocessingResultsKey];
NSString *pageTitle = jsPreprocessingResults[@"title"];
NSString *pageURL = jsPreprocessingResults[@"URL"];
if ([pageURL length] > 0) {
self.siteURL.text = pageURL;
self.URLstring = pageURL;
}
if ([pageTitle length] > 0) {
self.siteTitle.text = pageTitle;
}
});
}];
break;
}
}
}
[self queryParse];
}
-(void)queryParse{
PFQuery *query = [self.friendsRelation query];
[query orderByAscending:@"username"];
**[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (error) {
NSLog(@"%@ %@", error, [error userInfo]);
} else {
self.friends = objects;
[self.tableView reloadData];
}
}];**
}
【问题讨论】:
-
你的问题是什么?我猜您无法通过执行查询从解析中获取全部数据。
-
[查询 findObjectsInBackgroundWithBlock:^ 中的 Bock 不执行
标签: ios objective-c cocoa parse-platform ios-app-extension