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 · Nov 1, 2014 · 5465 views
    This topic created in 4390 days ago, the information mentioned may be changed or developed.
    目前有个需求,需要在用户第一次安装App、或者升级App的时候,将bundle中的sqlite文件拷贝拷贝到documents中。

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

    https://github.com/mysterioustrousers/MTMigration
    hustlzp
    hustlzp
    OP
    Nov 1, 2014
    4
    @PrideChung 好东西,谢谢推荐!
    edward9941
    edward9941
    Nov 2, 2014 via iPhone❤️1
    5
    在NSUserDefault里增加一个key,每次检查该key是否有值,如果没有就写入记录,这样下次再检查时就不执行if语句里面的内容了。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1480 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 04:32 · PVG 12:32 · LAX 20:32 · JFK 23:32
    ♥ Do have faith in what you're doing.