如何在iOS应用开发中的目标C中解决这个问题?

时间:2016-03-02 11:44:13

标签: ios objective-c iphone

在评论中给出,其中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];

}

0 个答案:

没有答案