- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在尝试获取 PFUser 的 PFObjects 列表以显示在 iOS 8 Today Widget 中。
关注此blog post通过 Parse,我在 Xcode 的主应用程序和扩展程序中启用了相同的应用程序组和钥匙串(keychain)共享。
我还在主应用程序的 AppDelegate
和 Today Extension 的 viewDidLoad
中启用了以下功能:
[Parse enableLocalDatastore];
[Parse enableDataSharingWithApplicationGroupIdentifier:@"group.com.me.myapp" containingApplication:@"com.me.myapp"];
[Parse setApplicationId:@"myAppId" clientKey:@"myClientId"];
在 widgetPerformUpdateWithCompletionHandler
中,我构造并执行了查询:
- (void) widgetPerformUpdateWithCompletionHandler:(void (^)(NCUpdateResult))completionHandler {
PFQuery *query = [PFQuery queryWithClassName:@"Note"];
[query whereKey:@"User" equalTo:[PFUser currentUser]];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error)
{
// check for difference between current and new data
if([self hasNewData:objects]) {
// fresh data
notes = objects;
[self.tableView reloadData];
[self updatePreferredContentSize];
completionHandler(NCUpdateResultNewData);
} else {
// Data is the same
completionHandler(NCUpdateResultNoData);
}
} else {
// Failed
completionHandler(NCUpdateResultFailed);
}
}];
}
}
第一次加载似乎工作正常 - 我能够获得我的 PFObjects 列表。但是,每当扩展第二次重新加载时,都会出现以下异常:enableDataSharingWithApplicationGroupIdentifier:containingApplication:' must be called before 'setApplicationId:clientKey''
is throw at the enableDataSharingWithApplicationGroupIdentifier
call in viewDidLoad
.
我可以通过将通知中心滑动到“通知”选项卡并将其滑动回来来复制此重新加载,这将导致再次调用 viewDidLoad。
我仔细检查了调用方法的顺序是否正确,甚至修改了顺序,但仍然发生崩溃。
有什么想法吗?提前致谢!
最佳答案
试试这个
if(![Parse isLocalDatastoreEnabled]) {
[Parse enableLocalDatastore];
[Parse enableDataSharingWithApplicationGroupIdentifier:@"group.com.me.myapp" containingApplication:@"com.me.myapp"];
[Parse setApplicationId:@"myAppId" clientKey:@"myClientId"];
}
关于ios - 在 iOS 8 Today Extension 中获取 parse.com 用户数据时出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30846723/
This question already has answers here: Using Variable for Thread group Ramp up time (3个答案) 3年前关闭。 从
我希望使用 RPyC 为硬件板提供 API 作为服务。该板一次只能满足一个用户的需求。有什么方法可以让 RPyC 强制执行一次只有一个用户可以访问吗? 最佳答案 我不确定这是否有效(或有效),但您可以
如果我想以每秒 10 个请求运行测试。如何让 Jmeter 选择每秒处理该请求数所需的最佳线程数。 我将线程数设置为与每秒请求数相同。 最佳答案 您可以使用恒定吞吐量计时器 click here你只需
我正在尝试进行查询以检查客户表并返回过去 30 天、过去 365 天和所有时间具有特定值的用户数。 所有时间的计数很简单: $stmt = $conn->prepare("SELECT count(i
我是一名优秀的程序员,十分优秀!