V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
hustlzp
V2EX  ›  iDev

[iOS 请教] 如何仅在用户第一次安装 App、或者升级 App 的时候执行一段代码?

  •  
  •   hustlzp ·
    hustlzp · 2014-11-01 11:52:34 +08:00 · 4574 次点击
    这是一个创建于 3461 天前的主题,其中的信息可能已经有所发展或是发生改变。
    目前有个需求,需要在用户第一次安装App、或者升级App的时候,将bundle中的sqlite文件拷贝拷贝到documents中。

    求教了。
    5 条回复    2014-11-02 09:31:04 +08:00
    SuperY
        1
    SuperY  
       2014-11-01 12:08:56 +08:00   ❤️ 1
    定义个key存version,每次启动检查version是否有记录,和是否大于当前记录。来确定要不要去拷贝
    hustlzp
        2
    hustlzp  
    OP
       2014-11-01 12:14:38 +08:00
    @SuperY 谢谢,很好的方法。
    PrideChung
        3
    PrideChung  
       2014-11-01 12:45:49 +08:00   ❤️ 2
    可以看看这个库,关键代码不到100行,可以照着做一个自己的版本

    https://github.com/mysterioustrousers/MTMigration
    hustlzp
        4
    hustlzp  
    OP
       2014-11-01 18:49:21 +08:00
    @PrideChung 好东西,谢谢推荐!
    edward9941
        5
    edward9941  
       2014-11-02 09:31:04 +08:00 via iPhone   ❤️ 1
    在NSUserDefault里增加一个key,每次检查该key是否有值,如果没有就写入记录,这样下次再检查时就不执行if语句里面的内容了。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3266 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 12:43 · PVG 20:43 · LAX 05:43 · JFK 08:43
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.