这真的取决于你需要/想要做什么。这两种方法都是有效且可行的。我亲自实施了两者。
以下是我可以告诉你的:
信息会改变:除非你正在编写一个关于数学的应用程序,否则事情很可能永远不会改变(除非最初有错误)。它可以使您的应用程序很快变得不正确/过时。发送应用更新需要一些时间。
互联网可能不可靠:您可以假设用户将有数据连接来下载应用程序。但是,这并不意味着他们第一次打开应用程序时就会拥有一个。有时他们会将其设置为下载并将其设备放在一边。他们可能稍后会打开应用程序,并且可能不存在数据连接。
You can do a mix of both: We developed an app that was meant as a self-guided tour of a place where there is poor cell reception. Visitors were encouraged to use the Information Center WIFI to download the app, but once they stepped out of the door it cell reception was poor/unavailable. We had to include a pre-populated SQL in the bundle. If there is no internet when the app is first opened, then it will load automatically from the bundle, otherwise it downloads it from a simple service (pretty much a dump) where information can be easily updated.
Again, it really depends on what you are trying to do and what your requirements and contraints are. In essence they are both valid and doable approaches. I personally prefer having a way to updating information without having to send an app update that, in my experience, can take weeks before it becomes publicly available.
There are libraries out there that will do most of the web service client implementation for you (JSON and XML parsers). Including them is fairly easy. All you have to do is to display that information through a url.
Back to your "can I include bundle a database" question. Yes, you can. This is how you can import a SQLite file from your bundle:
Do this in your persistendStoreCoordinator
in your app delegate
NSFileManager *fileManager = [NSFileManager defaultManager];
if(![fileManager fileExistsAtPath:directoryPath(@"YourSQLFile.sqlite")]) {
NSString *defaultStorePath = [[NSBundle mainBundle] pathForResource:@"YourSQLFile" ofType:@"sqlite"];
NSError *error = nil;
if(defaultStorePath) {
[fileManager copyItemAtPath:defaultStorePath toPath:[storeURL path] error:&error];
}
}