在评论中给出,其中counterData是另一个mutableArray 我使用openParentApplication 将数据从watch发送到ios 但是在vc.counterData,应用程序崩溃了
-(void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void(^) (NSDictionary *replyInfo))reply
{
NSString *counterValue = [userInfo objectForKey:@"counterValue"];
reply(@{@"insert counter value":counterValue});
if (!self.tempCounterData)
{
self.tempCounterData = [[NSMutableArray alloc] init];
}
[self.tempCounterData addObject:counterValue];
//Add the new counter value and reload the table view
AppDelegate *tmpDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
ViewController *vc = (ViewController *) ((UINavigationController*)tmpDelegate.window.rootViewController).visibleViewController;
vc.counterData = [[NSMutableArray alloc]initWithArray:self.tempCounterData copyItems:YES];//app crashing at this point, copying one array to another
[vc.mainTableView reloadData];
}