本文介绍了iOS SQLite.swift,关于app的升级?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 关于华丽而神奇的SQLite.swift,我想知道Regarding the magnificent and amazing SQLite.swift, I'm wondering你在应用程序商店中有一个应用程序,v7。有一个升级到v8。用户X使用应用程序商店将v7升级到v8。You have an app in the app store, v7. There's an upgrade to v8. User X does upgrade v7 to v8 using the app store.在v8中说,我们稍微改变了一个sql表,可能是添加一个列或重命名一列。Say in v8, we have slightly changed one of the sql tables, perhaps add a column or rename a column.在这种情况下,在SQLite.swift中是否应该执行任何特殊操作?Should anything or must anything special be done in SQLite.swift in this case? SQLite.swift处理它的方法是什么?What's the SQLite.swift way to handle that?(例如,Android有一个方便的 onUpgrade 助手类中的概念......它附带了它自己的一系列复杂问题。)(In for example, Android there's a handy onUpgrade concept in their helper class ... which comes with it's own set of complex issues.)推荐答案 SQLiteOpenHelper 非常简单: db = SQLiteDatabase.openDatabase(...); onConfigure(db); int version = db.getVersion(); if (version != mNewVersion) { db.beginTransaction(); try { if (version == 0) { onCreate(db); } else { if (version > mNewVersion) { onDowngrade(db, version, mNewVersion); } else { onUpgrade(db, version, mNewVersion); } } db.setVersion(mNewVersion); db.setTransactionSuccessful(); } finally { db.endTransaction(); } }在Swift中也一样。Just do the same in Swift.关于如何实施 onUpgrade(),请参阅 SQLiteOpenHelper onUpgrade()混淆Android 。For how to implement onUpgrade(), see SQLiteOpenHelper onUpgrade() Confusion Android. 这篇关于iOS SQLite.swift,关于app的升级?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-01 12:02