Reputation: 263
I am trying to send an array to the InterfaceController with the following method within the App Delegate:
- (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void (^)(NSDictionary *))reply
{
NSLog(@"Request received by iOS app");
NSMutableArray *mutableArray = [[NSMutableArray alloc] initWithCapacity:20];
for (NSDictionary *object in [[NSUserDefaults standardUserDefaults] objectForKey:@"reminders"]) {
NSString *subject = object[@"subject"];
[mutableArray addObject:subject];
}
NSLog(@"MUTABLE ARRAY: %@", mutableArray);
NSDictionary *dictionary = [[NSDictionary alloc] initWithObjectsAndKeys:mutableArray, @"key", nil];
reply(dictionary);
}
And in the Interface Controller:
- (IBAction)callPhoneAppButtonTapped
{
NSDictionary *dictionary = [[NSDictionary alloc] initWithObjectsAndKeys:@"text to display", @"key", nil];
[InterfaceController openParentApplication:dictionary reply:^(NSDictionary *replyInfo, NSError *error) {
NSLog(@"Reply received by Watch app: %@", replyInfo);
}];
}
The problem is I can see the array in the App Delegate but I cannot read the reply in the InterfaceController of the Apple Watch?
Any suggestions on this approach or a better approach to send an array to the InterfaceController in order to create a Table?
Upvotes: 1
Views: 766
Reputation: 2285
In watchOS2 they introduces a nice feature called WatchConnectivity. Please look at my reply to this question: How to send data from Iphone to Apple Watch in OS2 in Objective-C
Its easy to send an array instead of String/NSNumber.
Upvotes: 1