iOS Development-Network & Database Features overview

Source: Internet
Author: User
Tags network function sqlite database sqlite server

Learning experience is shallow, previously iOS development has been stuck in a standalone version of the development, but now if a mobile development completely abandon the network function, it will not exist for a long time. Online about the iOS network parts are more exclusive, the two days after the fusion and summary, roughly explore a set of overall process, in this and the network connection is not very clear to the students to share, this article does not involve the technical level, but the concept of collusion.

Premise Note: If you are really just developing a standalone app or the company has encapsulated the network data to give you an interface or XML format and so on and do not want to know, please just ignore me.

I. Overview of premises

First of all, to consider what level of environment the app is in, I broadly divide the environment into the following

1. Personal development, single version app

If there is no data Exchange store at this point, ignore this article

If there is data storage and operation, use Coredata/nsarray (Nsdictionay), in this case almost do not need to directly manipulate SQLite (after the pros say)

2. Personal development, web-version app

At this point, if there is no network data storage, such as just a plate into a map and just show the map data, just use the Mapkit or Google API to

If you simply get some of the merchant's packaged network data. For example, to get itunes subscription, you need to use the XML parsing function (Nsxmlparser, third-party framework) or JSON parsing function (same kind)

If the data needs to be increased and censored in both cases, server interaction or local CoreData (not recommended to operate the database directly) is required.

3. Team development, single version of the app (really pure standalone version)

I don't think that's possible.

4. Team development, web-version app

This is also true for individuals who want to develop a companion web application

At this point, if the web side and server interaction are done by the other team, do your own thing

If the individual wants to do the whole stack of work, but also need to understand at least the network protocol and proficiency in the use of at least one server script (such as PHP, node. js, etc.), SQL, and then consider the Web front-end to make the web version of the application. Using programming languages such as Java to do business logic is too much work for a personal developer, and if you do, you really need to think about forming a team ...

For the above, I summarize the experience of individual developers, a professional team, professionals more important, not the full stack of engineers

Second, network data operation

This section is about network data only, regardless of the server or database.

One is a ready-made, packaged network of data, such as Mapkit and Google Maps, so that you can use the framework to achieve most of the functionality.

One is the data Interchange format provided by the Merchant XML, JSON, RSS, etc., at this time is to learn XML parsing (bring Nsxmlparser, or Gdataxml and other third-party libraries, the use of third-party libraries on the web, the analysis of the self-brought some cumbersome, I do not deny that the third-party library simpler and clearer, But Nsxmlparser is more able to reflect the sax analytic way of thinking routines, JSON parsing. Now the main is the XML, JSON these two formats, large companies have JSON format for you, but also can not avoid some you really want to use the data company only provide XML.

Here because I think the team is not enough level, third-party companies will not give you the opportunity to interact with the server autonomously, but will give you API operations. Not to mention is the personal development, mainly in the operation of data exchange file-based.

Third, network operation with server and database

Explain some of the basic concepts, because iOS development is strictly a client-side development, the server database part is just icing on the cake, so some novice like me just did web,ios development of children's shoes, for the overall process may not know. Especially on the mobile side, a company will not use the mobile side of the platform to develop operations.

There are two ways to get data from a network database in the end

1. Client-database mode, the general situation is very not recommended, one is because the direct operation of the database code cumbersome, should not update maintenance, such as a large number of connection close operations, SQL operations, when the table attribute information changes, the change in the workload is very large. The second is that the database of the pretext information will be exposed to the client, insecure, the database must be placed in the rear.

2. Client-server-database mode, this mode is the normal mode, the server encapsulates the operation of the database, only to make the request to the server and then receive the response data. The request is made here in the Get/post two main way, the former has the field length limit, belongs to obtain the data through the URL operation, the latter belongs to sends the request to the server, the server processes the request to give a response to return to the client, this way is more commonly used , there is no capacity limit in theory, regardless of the computing power of the server. Get is only useful for getting a small amount of data, because you can't put a lot of data, such as video, in a file that a URL points to for you to call. Post can be packaged by the server operation, more efficient operation of a large number of data, such as video upload and download, please refer to the relevant articles.

Secondly, I divide the data into the following situations

1. Data only needs to be operated in a single machine (small amount)

General data stored two Nsarray or nsdictionary got

The cache for user login information is stored locally via CoreData (2nd detail)

2. The database requires only a single machine operation (a large number of)

At this time CoreData is the first choice, explained that CoreData is not a database, is a data persistence technology, haha this concept to listen to and not listen to the same, popular, CoreData is Apple's good package of SQLite database, The developer can operate the SQLite database more efficiently through CoreData, which is equivalent to the program and the SQLite intermediary.

So it should be understood here that there is a problem that may be bothering the novice, what is the difference between CoreData and SQLite?

If for CoreData and SQLite itself, is not a concept, because the final operation is SQLite. Not to say the difference, refers to the operation of CoreData and direct operation of SQLite what is the difference. CoreData is to object to the SQLite and then operate, if the Oracle or MySQL have experience of children's shoes, it is not difficult to understand the meaning of database instantiation, after all, now everything is popular object-oriented! The advantage of CoreData is that it is like connecting your MVC program and SQLite server, encapsulating the database, changing the properties of the SQLite table, or exchanging a database instance for easy data transfer. Direct operation SQLite is generally cumbersome and difficult to maintain, but if you need to perform advanced operations on the database, CoreData may not meet you, then need to put aside CoreData direct Operation SQLite.

CoreData also has one of the biggest advantages is that through the Nsfetchedresultscontroller and its delegate method, can realize when the addition and deletion of the database to update the page display data real-time updates, like Ajax haha

3. Data needs to be exchanged on the network (small, public)

In this case, I think the current mobile is not used to do server and database background development, so generally speaking in addition to user information and certain industry-specific applications (such as banks, etc.), most of the data is open network data, with the most reliable data exchange, the advantage is simple, fast. Additions and deletions to json/xml operation can be implemented in iOS.

This is the preferred JSON, up-and-comer, lightweight data Interchange format, easy to use, and clear thinking, in the development of iOS is recommended

If not, a lightweight third-party framework, such as Tbxml,gdataxml, that uses XML, such as the third-party framework, is much faster than the original, but only when dealing with a small amount of data.

Http://mobile.51cto.com/iphone-281283.htm

4. Data needs to be exchanged on the network (small, secure transmission)

This situation is most common is the user login authentication, at this time need to interact with the server, send HTTP request (Post,post security, because it needs to be processed by the server)

Oldest nsurlconnection (already deprecated, and operating in the main queue, too slow)

IOS7 recommended after Nsurlsession (can be asynchronous processing, details click here, my other article)

Third party afnetworking (as with nsurlsession, my personal test feels the fastest)

ASIHTTPRequest, the year is very cow, but a long time no update, the first two days with a bit, if your program opened the ARC mode, has been unable to use, because this framework is in the manual control of Memory in the era of writing

At this point do not think how to connect directly with the database operation, you are equal to all the user information exposed to any mobile side

5. Data needs to be exchanged on the network (mass, public)

Num 1. You need a chunk of the data. If it's the way data is exchanged, the DOM-level framework for JSON and XML might not be enough for you. The recommended fruit comes with XML parsing NSXMLPARSER,LIBXML2, support for Sax parsing, the difference between sax and DOM, and the basic implementation of Nsxmlparser Click here, I wrote an article.

Num 2. You need a lot of data in one of the bars. Please send a request to the server (the Xml,json code may be verbose at this time). Do not want to connect the database, the database interface information as the server interface information to do, and then make the corresponding additions and deletions to check.

Num 3. You need a lot of data, maybe the XML DOM way and JSON will be faster, I haven't tested a lot of data.

6. Data needs to be exchanged on the network (mass, secure transmission)

This should not be seen on the mobile side, that's the thing about the internal Web project.

This article is intended to provide an easy-to-understand web guide for iOS Personal development beginners, and if there are any errors, please correct them.

If you're interested in building Web servers and databases, let me know in the comments that I've built an AWS EC2 with AWS Rds, and then I'll write a little bit about that.

Welcome to my homepage http://www.jiachengzhi.com/

iOS Development-Network & Database Features overview

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.