Ios `UIApplicationLegate`to`WKInterfaceController`数据传递
关于如何将此数据从我的iOSIos `UIApplicationLegate`to`WKInterfaceController`数据传递,ios,objective-c,parse-platform,watchkit,Ios,Objective C,Parse Platform,Watchkit,关于如何将此数据从我的iOSAppDelegate.m传递到我的WatchKitInterfaceController.m有什么想法吗 我在iOSAppDelegate.m - (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void(^)(NSDictionary *replyInfo))reply {
AppDelegate.m
传递到我的WatchKitInterfaceController.m
有什么想法吗
我在iOSAppDelegate.m
- (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void(^)(NSDictionary *replyInfo))reply {
NSString * request = [userInfo objectForKey:@"requestString"];
if ([request isEqualToString:@"executeMethodA"]) {
// GMT Date from Phone
NSDate *gmtNow = [NSDate date];
NSLog(@"GMT Now: %@", gmtNow);
// Query Parse
PFQuery *query = [PFQuery queryWithClassName:@"na"];
[query whereKey:@"dateGame" greaterThanOrEqualTo:gmtNow];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
NSMutableArray *localMatchup = [@[] mutableCopy];
for (PFObject *object in objects) {
// Add objects to local Arrays
[localMatchup addObject:[object objectForKey:@"matchup"]];
// App Group
NSString *container = @"group.com.me.off";
NSUserDefaults *defaults = [[NSUserDefaults alloc] initWithSuiteName:container];
// Matchup
[defaults setObject:localMatchup forKey:@"KeyMatchup"];
NSArray *savedMatchup = [defaults objectForKey:@"KeyMatchup"];
NSLog(@"Default Matchup: %@", savedMatchup);
}
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"dispatch");
});
reply(@{@"localMatchup": localMatchup});
}
else {
reply(@{@"error": error.description});
}
}];
}
}
很高兴发布任何额外的代码,请提问,谢谢 在您的
handleWatchKitExtensionRequest
方法中有一个reply
块,请在完成查询时使用dict中的数据运行它
reply(@{@"localMatchup": localMatchup});
在
handleWatchKitExtensionRequest
方法中有一个reply
块,当您完成查询时,使用dict中的数据运行它
reply(@{@"localMatchup": localMatchup});
在
handleWatchKitExtensionRequest
方法中有一个reply
块,当您完成查询时,使用dict中的数据运行它
reply(@{@"localMatchup": localMatchup});
在
handleWatchKitExtensionRequest
方法中有一个reply
块,当您完成查询时,使用dict中的数据运行它
reply(@{@"localMatchup": localMatchup});
我想你可以调用handleWatchKitExtensionRequest方法我想你可以调用handleWatchKitExtensionRequest方法我想你可以调用handleWatchKitExtensionRequest方法谢谢你的回复!是的,我假设我需要
reply
块,但我不知道,因为我在查询中得到了一个array
,当我执行reply
部分时,我应该如何将它放入dict
中。有什么想法吗?只要把它放在字典里{“parseArray”:arrayFromParse}@SRMR是的,你可以把它放在那里。此外,我认为最好在发生错误时也回复一条错误消息。将其放在其他地方的一个单独的回复中,或者做一个NSLog?@SRMR您已经有了!如果条件出现错误
只需向其添加一个else
,并回复如下内容回复(@{“error”:error.description})
。感谢您的回复!是的,我假设我需要reply
块,但我不知道,因为我在查询中得到了一个array
,当我执行reply
部分时,我应该如何将它放入dict
中。有什么想法吗?只要把它放在字典里{“parseArray”:arrayFromParse}@SRMR是的,你可以把它放在那里。此外,我认为最好在发生错误时也回复一条错误消息。将其放在其他地方的一个单独的回复中,或者做一个NSLog?@SRMR您已经有了!如果条件出现错误
只需向其添加一个else
,并回复如下内容回复(@{“error”:error.description})
。感谢您的回复!是的,我假设我需要reply
块,但我不知道,因为我在查询中得到了一个array
,当我执行reply
部分时,我应该如何将它放入dict
中。有什么想法吗?只要把它放在字典里{“parseArray”:arrayFromParse}@SRMR是的,你可以把它放在那里。此外,我认为最好在发生错误时也回复一条错误消息。将其放在其他地方的一个单独的回复中,或者做一个NSLog?@SRMR您已经有了!如果条件出现错误
只需向其添加一个else
,并回复如下内容回复(@{“error”:error.description})
。感谢您的回复!是的,我假设我需要reply
块,但我不知道,因为我在查询中得到了一个array
,当我执行reply
部分时,我应该如何将它放入dict
中。有什么想法吗?只要把它放在字典里{“parseArray”:arrayFromParse}@SRMR是的,你可以把它放在那里。此外,我认为最好在发生错误时也回复一条错误消息。将其放在其他地方的一个单独的回复中,或者做一个NSLog?@SRMR您已经有了!如果条件出现错误
只需向其添加一个else
,并回复如下内容回复(@{“error”:error.description})
。感谢您的回复!我想这就是我正在使用的方法,对吗?谢谢你的回复!我想这就是我正在使用的方法,对吗?谢谢你的回复!我想这就是我正在使用的方法,对吗?谢谢你的回复!我想这就是我正在使用的方法,对吗?