IOS App version 2.0 What to Do (go)

Source: Internet
Author: User
Tags md5 encryption

mobile internet in full swing, IOS app + Android app + mobile phone station seems to be the standard of all Internet companies, your site if you do not have an IOS app, it seems embarrassed to greet people.
IOS apps are born in less than 5 years after all, all aspects are still in the initial stage. The first version of these iOS apps is often rudimentary, especially in the technical architecture, whether it's the team's inexperience or the "fast-breaking" iron rule. This article, I want to talk to you about this question, when your iOS app already has a version of the online situation, how to build a can support efficient iteration, rapid Response version 2.0.
first, the architecture of the application needs to be clearly layered. Change the version without relying on the version update, since the changes in the revision, do not need to change the business logic, view logic, tools, such as the content of the comb clear, separate processing.
?
Figure 1, applying the overall architecture
bottom-up, the bottom line is the API Server, which is the service side, and often trampled on the general network of stools, this article focuses on the client architecture, the two layers do not say much.
Network and local Storage are the data sources for the entire application. The Local Storage also caches data from the network in addition to storing resource data. In this layer, all data is present in the original unformatted structure, or text, or arrays and dictionaries of text.
Network is a bridge between client and server, and it is generally recommended to use open source controls (such as: afnetworking). In the case of a stool-like network, there are various exceptions to the request, so the request control methods provided in these controls provide a lot of convenience to handle these problems.
Local Storage divided into files as direct storage of images and other resource files, information class data, such as: User information, configuration information, etc., it is recommended to use the core data provided in the cocoa framework, a very good package for SQLite. Direct use of file storage to pay attention to the write frequency, high frequency I/O operations are very resource-intensive, in general, the data directly in memory, and only when necessary, such as: Shutdown application or key data write (user password) to write back.
Items are the encapsulation of data objects throughout the application, and in a way a collection of value object. Item of a data type can be the most primitive array or dictionary, or it can be encapsulated into a pojo in Java, or a more complex data object with a basic processing method. Data Center is the control center of items, which fully encapsulates network requests, network exception handling, caching mechanisms, and so on. Data Center responds to requests from the upper layer, requesting the original data from the network or local Storage, and assembling it into the data structure defined in items and returning it to the upper layer.
Services is the encapsulation of business logic, and Data Center focuses on how to get items,services and how to organize items, such as: How to build search parameters, how to page, list sort, etc. Services encapsulates complex business logic into class names, method names, and parameters for upper-level invocation. The change in this layer is much more frequent than the layers mentioned above, as services change with the business and are not purely technical.
The View Controllers, as the name implies, is the viewcontroller in the Cocoa Framework, where only the display logic is present in these viewcontroller. This layer does not care what the returned items mean, why it is so combined, and the view Controllers only cares what the items need to view, what colors to use, etc.
Tools is an almost complete application tool and extension collection, tools such as: string MD5 encryption, array flattening, etc., extensions such as: UIView framework settings, URL assembly, and so on.
under this architecture, Items and tools are almost static and have no logic. Network, Data Center, and local Storage encapsulate logic from a technical perspective, with little change in the version iterations. Services This layer is the focus of the revision iteration, and his thickness depends on the business complexity of the application. The content of the View Controllers changes more frequently, does not even rely on the version update, needs through the API Server's information modification interface display, needs the high customization.
building an iOS app in the framework described above can make the code hierarchy of the entire project clear, yet an efficient Internet application, with only a clear level of clarity, is far from enough, and there are many other ways to reduce the development and operational costs of the application.
first, proper use of webview can greatly improve application flexibility and reduce development costs. Using WebView to differentiate yourself from creating web apps, creating a Web App is a visual control of the entire app that is created entirely based on WebView, with a small amount of local code-assisted interaction, and here's what's said in an app that uses WebView without compromising the visual and interactive experience. Complete part of the visual element.
There are two ways to use WebView in your application, one is to create the entire view using WebView, which is suitable for non-critical interfaces, and there are still many details that need to be adjusted in order to reduce costs or to be in the beta phase of the interface. This kind of usage is webview high complexity, need to implement cookie record in WebView, HttpRequest custom, interact with local code and so on.
?
Figure 2, the complex webview
For example, the FAQ page, which is a non-critical page, but the content changes are more frequent, so use webview to achieve. This webview interface does not do any camouflage, is a native webview style, in the actual application, if the visual requirements are high, you can modify Navigationbar, toolbar and webview some unique gestures to disguise, Make it look more like a local view.
?
Figure 3,faq
The other is webview embedded in native code that is suitable for displaying more complex visual elements, either loading content directly from the network by WebView, or loading HTML code separately to render locally. This webview is much simpler to use than the previous one, just to implement the part that interacts with the local code.
?
Figure 4, the simple WebView
Weibo details page of Sina Weibo is implemented in this way, the text and source of Weibo are implemented using WebView, the other part is local code. Due to the fact that there are more expressions in the text of Weibo, the situation of picture-and-text blending is more complicated, so using local webview is a very good method.
?
Figure 5, Weibo details page
outside of WebView, a lot of interaction and vision is managed by the local Vision Controller (viewcontrollers), where traditional iOS apps are stored Viewcontrollers objects from stacks in Uinavigationcontroller, Managed directly through push and pop methods. The viewcontrollers coupling in this way is very strong, and there is a dependency between them and cannot exist alone. Strong coupling is always troublesome in coping with changes, so it is necessary to modify and encapsulate this strongly coupled method to suit the characteristics of Internet applications.
using URL Scheme management viewcontrollers was originally developed by Facebook for the THREE20 framework implementation (since the framework was officially abandoned, it is not recommended, https://github.com/gaosboy/ Urlmanager is a lightweight, open source URL Scheme management control). URL Scheme is characterized by the fact that the information required in Viewcontroller is passed through the parameters, and the Viewcontroller is marked, created, and managed through a URL.
?
Figure 6,url Scheme schematic diagram
the principle of URL Scheme is to maintain a relational table of Url–viewcontroller Class Name, in which the developer defines a private protocol to differentiate the URL of the HTTP request, for example: sf://. Viewcontrollera when you need to call Viewcontrollerb, you first construct a URL that is relative to B, passing in the URL manager. The manager finds the relative Viewcontroller by checking the relational table and initializes the live object instance through the Nsclassfromstring method. In this instance initialization process, to complete the resolution of its URL, from the URL parameters and path to get the next attempt to render all the information required.
through the URL Scheme management Viewcontrollers can be implemented from any viewcontroller to arbitrary viewcontroller calls, and these calls are completely dynamic, only need to construct a URL to join the corresponding parameters, The decoupling between the Viewcontroller is realized.
Segmentfault Official application is a practice of the principles and architecture described above, and you can obtain the code for the project by Https://github.com/gaosboy/iOSSF. Each iOS app has its own unique characteristics, which is determined by the business characteristics of the application itself, so a set of architecture system can not fully adapt to the application of its own characteristics, in the above mentioned principles of the framework to make reasonable adjustments to establish a use of their own application of the architecture system. In the iOS app development process, encounter any problems can go to Http://segmentfault.com/t/ios to communicate, let everyone help you build a reasonable application.
in short, the most important point in the transition from 1.0 to 2.0 is that the application architecture tends to be reasonable, that the technical reserves of the next iteration are well-prepared to cope with the rapidly changing needs, and that the pace of the iteration of the version will keep up with the pace of demand change.

Original link: http://pingguohe.net/2013/02/14/version_2_0/

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.