Any ideas on how to pass this data from my iOS AppDelegate.m
to my WatchKit InterfaceController.m
?
I run a Parse
query in my iOS AppDelegate.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});
}
}];
}
}
Happy to post any extra code just ask, thanks!
There is a reply
block in your handleWatchKitExtensionRequest
method, run it with your data in a dict when you finish your query.
reply(@{@"localMatchup": localMatchup});