-(void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void (^)(NSDictionary *))reply
{
__block UIBackgroundTaskIdentifier watchKitHandler;
watchKitHandler = [[UIApplication sharedApplication] beginBackgroundTaskWithName:@"backgroundTask"
expirationHandler:^{
watchKitHandler = UIBackgroundTaskInvalid;
}];
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
if ([[userInfo objectForKey:@"request"] isEqualToString:@"NearestFacility"]) {
[self NearestFacilityClicked];
if (self.ary_WatchKitNearestFacility.count>0) {
NSDictionary *response = @{@"response" : self.ary_WatchKitNearestFacility};
reply(response);
; }
}
dispatch_semaphore_signal(sema);
dispatch_after(dispatch_time( DISPATCH_TIME_NOW, (int64_t)NSEC_PER_SEC * 1), dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[[UIApplication sharedApplication] endBackgroundTask:watchKitHandler];
});
}
when trying to send NSMutableArray
to Watch from iPhone app extension then it gives below error.
Error Domain=com.apple.watchkit.errors Code=2 "
The UIApplicationDelegate
in the iPhone App never called reply()
nsmutablearray
can anyone help me , how can I send NSMutableArray
to watch from iPhone app, and this is dynamic array coming from REST request.
Thanks in advance