zoukankan      html  css  js  c++  java
  • ios修改了coredata数据结构后,更新安装会闪退

    如果iOS App 使用到CoreData,并且在上一个版本上有数据库更新(新增表、字段等操作),那在覆盖安装程序时就要进行CoreData数据库的迁移,具体操作如下:

    1.选中你的mydata.xcdatamodeld文件,选择菜单editor->Add Model Version  比如取名:mydata2.xcdatamodel

    2.设置当前版本

       选择上级mydata.xcdatamodeld ,在inspector中的Versioned Core Data Model选择Current模版为mydata2

    3.修改新数据模型mydata2,在新的文件上添加字段及表

    4.删除原来的类文件,重新生成下类。(这一步没有做)

    在appdelegate中


    NSDictionary *optionsDictionary = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES],
                                           NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:YES],
                                           NSInferMappingModelAutomaticallyOption, nil];
        
    if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType
                                                      configuration:nil
                                                                URL:storeUrl
                                                            options:optionsDictionary
                                                              error:&error]) {

              NSLog(@"failed to add persistent store with type to persistent store coordinator");

    }

    添加 *optionsDictionary,原来options:nil  改成options:optionsDictionary
    5.重新编译下程序

  • 相关阅读:
    【转】P2P通信原理与实现(C++)
    【转】P2P通信标准协议(二)之TURN
    【转】P2P之UDP穿透NAT的原理与实现
    【转】P2P的原理和常见的实现方式
    【转】linux中man使用技巧
    【转】go编译时,加入svn版本信息
    各种移动GPU压缩纹理的使用方法
    Unity贴图压缩格式设置
    关于U3D贴图格式压缩
    可能会导致.NET内存泄露的8种行为
  • 原文地址:https://www.cnblogs.com/Free-Thinker/p/7094713.html
Copyright © 2011-2022 走看看