我正在尝试使用 App Delegate 中的以下方法将数组发送到 InterfaceController:
- (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);
}
在接口控制器中:
- (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);
}];
}
问题是我可以在 App Delegate 中看到数组,但在 Apple Watch 的 InterfaceController 中看不到回复?
关于这种方法或将数组发送到 InterfaceController 以创建表的更好方法的任何建议?