2013-07-17 146 views
0

我有一个现有的应用程序(在appStore中可用),我想从头开始重新启动,并将其作为更新。所以我开始了一个新的项目,并像旧的项目一样重现所有相同的(名称,bundleId,xcdatamodel等)。ios应用程序权限被拒绝更新应用程序

我想测试数据是否保存良好,当我更新旧的应用程序与新的,但是当我建立它时,我从xcode“申请权限被拒绝”这个错误。

我读到,这个错误是由于我尝试安装一个应用程序与设备上已存在的相同bundleId。我不明白,因为我试图模拟更新。

我能做些什么来得到这个工作?

+0

似乎更新与存档和iTunes同步工作,而不是直接从xcode工作,但我不知道数据是否已经存在...这是不是真的很实际调试像这样... – Bejil

回答

0

好的,这是帮助我的解决方案。

  • 构建一个档案安装它使用iTunes而不是xcode直接构建。
  • 另一个问题是,当xcode可用时,该应用的第一个版本是为第一个iPad构建的,但这些设备尚未售出。这里是老 - 使用(NSPersistentStoreCoordinator *)persistentStoreCoordinator方法:

-(NSPersistentStoreCoordinator *)storeCoorditator{ 
    if(storeCoorditator){ 
     return storeCoorditator; 
    } 

    storeCoorditator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self objectModel]]; 
    NSError *lc_error = nil; 

    NSString *lc_path = [NSString stringWithFormat:@"%@/data.sqlite",[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]]; 

    NSURL *storeUrl = [NSURL fileURLWithPath:lc_path]; 

    NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys: 
          [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, 
          [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil]; 

    [storeCoorditator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:options error:&lc_error]; 
    return storeCoorditator; 
} 

,这里是我试图使用方法:


-(NSPersistentStoreCoordinator *)persistentStoreCoordinator{ 
    if (_persistentStoreCoordinator != nil) { 
     return _persistentStoreCoordinator; 
    } 

    NSURL *storeUrl = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"PDF.sqlite"]; 

    NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys: 
          [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, 
          [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil]; 
    NSError *error = nil; 
    _persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]]; 
    if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:options error:&error]) { 

     NSLog(@"Unresolved error %@, %@", error, [error userInfo]); 
     abort(); 
    } 

    return _persistentStoreCoordinator; 
} 

由于storeUrl是不一样的,数据找不到;) 现在一切正常,我可以把我的数据回来!

相关问题