简体   繁体   English

iOS开发。 MySQL的? SQLite的? 什么是最好的方式?

[英]iOS development. Mysql? Sqlite? what's the best way?

I need to create an app linked with a remote database! 我需要创建一个与远程数据库链接的应用程序! Is mysql the best solution? mysql是最好的解决方案吗? Is Sqlite an only-local solution? Sqlite是唯一的本地解决方案吗?

I use the following method and I would to know if it is the best way! 我使用以下方法,我想知道它是否是最好的方法!

NSString *evento = @"1";
NSString *filtro = @"CAC2";

NSString *strURL = [NSString   
stringWithFormat:@"http://www.xxxxxxx.com/Scripts/Evento/WIGriceviTipo.php?  
evento=%@&filtro=%@",evento, filtro];

NSData *dataURL = [NSData dataWithContentsOfURL:
               [NSURL URLWithString:strURL]];

NSString *strResult = [[NSString alloc] initWithData:dataURL   
encoding:NSUTF8StringEncoding];

strResult = [strResult stringByTrimmingCharactersInSet:[NSCharacterSet       
whitespaceAndNewlineCharacterSet]];

mostra.text=strResult;

NSLog(@"%@", strResult);

Why not use Core Data ? 为什么不使用Core Data I do lots of remote database interaction and use CD for the local storage and just pass all the data to a web-service that digests it, checks for data integrity and then passes along the data to the database. 我做了很多远程数据库交互,并将CD用于本地存储,只是将所有数据传递给消化它的Web服务,检查数据完整性,然后将数据传递给数据库。

Core Data is a much easier learning curve than you might think and if you use a third party library like Magical Record , it is even easier. Core Data是一个比你想象的更容易学习的曲线,如果你使用像Magical Record这样的第三方库,它就更容易了。

As far as the web server database goes, MySQL is the best option (IMO) if you are using a Linux based platform, SQL Server becomes an option if you are going the Windows Server route. 就Web服务器数据库而言,如果您使用的是基于Linux的平台,MySQL是最佳选择(IMO),如果您使用Windows Server路由,SQL Server将成为一个选项。

SQLite shouldn't be used remotelly. SQLite不应该用于remotelly。 From doc: 来自doc:

If you have many client programs accessing a common database over a network, you should consider using a client/server database engine instead of SQLite. 如果您有许多客户端程序通过网络访问公共数据库,则应考虑使用客户端/服务器数据库引擎而不是SQLite。

In your code you could make this request asynchronous because you might be blocking your main thread while data is being retrieved. 在您的代码中,您可以使此请求异步,因为您可能在检索数据时阻塞主线程。 You may use GCD and enclose dataWithContentsOfURL with dispatch_async or use NSURLConnection class instead. 您可以使用GCD并将dataWithContentsOfURLdispatch_async使用,或者使用NSURLConnection类。

Different versions of SQLLite can be use remotely and it is better to have SQLLite database in mobile application development because it occupy low memory to store the data. 可以远程使用不同版本的SQLLite,最好在移动应用程序开发中使用SQLLite数据库,因为它占用的内存很少,无法存储数据。

Please visit http://www.sqlite.org/cvstrac/wiki?p=SqliteNetwork 请访问http://www.sqlite.org/cvstrac/wiki?p=SqliteNetwork

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM