iOS Fury Trail (START)---learning route summary

Source: Internet
Author: User
Tags php language

I. Learning route planning

Android and iOS are the two biggest platforms on the move today, but who can guarantee that the two platforms will thrive for a lifetime? Nobody can guarantee that one will become the second Nokia in the next few years, so we will now Android students should consider learning iOS, will iOS classmates also want to consider learning Android. So from the beginning of this article we will start our iOS learning journey, but the premise is that you will have some basic C language grammar and OC Grammar and Android development experience, about C, this is a university must learn a course, so do not know the students need to do their own, and the introduction of OC Grammar , before I have very detailed introduction of the more than 10 chapters, do not know the students can click here: OC Learning Summary Of course, if you have the development experience of Android, then it is more convenient and easy to learn, because iOS and Android in many ways have similarities, Some places may be exactly the same, just the API is different, and in the subsequent introduction, OC syntax and Java syntax will be compared, iOS and Android to compare the explanation. Here's a look at our route to learning iOS:

Through a picture above, we can see that the learning route of iOS and the original Android learning route, in the mobile platform, in fact, the main is the four core basic modules: UI control view usage, multi-threading, network access, data local storage; just figure out the four core points In addition to follow-up project practice, as well as subsequent experience accumulation, iOS advanced is still very simple, and later will find that iOS has some features encapsulated so good that it is not as complex as Android, such as saving user settings information, in iOS with two lines of code to complete, In Android, you may need to 6~7 lines of code to do it. There is one of the most important point is the implementation of animation effect, the students who have done Android should know that in the Android to achieve some special animation or more laborious, in iOS implementation is very simple, the simple reason is that he put the API encapsulation is too good, we just want to call the Fool, Of course, you have to know his principles. Here are some one by one things to explain:

Ii. Summary of Learning route knowledge First, C language basic knowledge explanation

As a computer science, C language should be a necessary course in the university, whether you finally choose Java or PHP language, C is the most core of C language, so-called C language is roughly the same grammar, such as JAVA,C++,OC, such as the C-series language, So these languages learn from each other is very simple, of course, before there are B-series language, such as B language, VB, and their grammatical structure is very similar.

So why do we have to understand the basic knowledge of C language? When learning Android, in fact, the follow-up to the development of the NDK, C language must be mastered, he is the core base language, because the subsequent development of iOS will use OC language as the basis, then in the development, will find in the iOS program will often use some C language functions and functions, So the C language must be mastered, but our most important thing is to grasp the C language of the core of a few knowledge points: pointers, structures and arrays; about other things like Java, if you've learned Java, there's a maximum number of pointers in iOS development. To be exact, as long as in iOS if you define a type that starts with NS, it is generally a pointer type, such as: nsstring* str; If the struct type is generally cgrect rect, then from this point we can distinguish the type structure very well, Another important point for pointers is the ability to get multiple return values from a function, which is often used in development, such as having a way to perform a function in iOS development, and we want to know what the results of this method are doing, and what the process information is. So this is definitely going to return two messages, in Java We may customize a type to encapsulate both information, or use a callback mechanism, but in OC you can use pointers directly as a return state of information, such as: BOOL xxx_yyy: (Nsinteger) arg1 ZZZ: (nserror**) error; Here we see the last parameter can get the error message of the function execution from the function, see that he is a level two pointer, we only need to define a nserror* Error1 = nil in the outside, then use the &error1 pass the parameter to enter, finally can obtain this information, here The & is the address of a variable, so seeing the pointer is the address, and the address is the pointer.

Speaking of pointers, there is also an important point of knowledge is the function pointer, about function pointers can be thought of as similar to the callback function in Java, you can pass a function pointer type in a function, using function pointers inside the function to invoke the function function In OC, of course, a callback mechanism is simply called a protocol function, similar to the type of interface in Java.

Second, OC Language Foundation review

Many years ago, I have introduced all the basic knowledge of OC, if you do not know the students, you can click here to view: OC Learning route summary at the time the explanation is very detailed, but not all knowledge will be used, such as predicates these functions may be less. But some of the core knowledge points are still more.

1, the definition of the class in OC and the definition of the method

Although OC and Java belong to the C-series language, but their grammatical structure is still somewhat different, such as their definition of the way the class is very different, so learning Android students to iOS just start the first step is to write more code more accustomed to OC syntax. Creating a new class in OC produces two files, one is the header file. h, there is also a class implementation file. m; The type of this class is defined in the. h file:

@interface Class Name: nsobject{
Defining properties
Defining methods


In. m is generally a concrete implementation of a class:


Implementation Method method


As you can see here, the defined class in OC does not use {}, but instead uses the @ keyword to divide the region.

The definition of methods in OC is somewhat different from Java:

Method description (return type) method name: (parameter type) parameter name
1. There are two types of methods:
One is a minus sign: "-", which means that the method is an object method, that is, an object instance must be used to invoke the
One is the plus sign: "+", which means that the method is a class method, which can be called directly from the class, and does not need to instantiate the object, similar to the static method in Java
2 ", return type: This is simple, and the Java language is very similar

The above is the format for defining classes and methods in OC, which then involves several core points of knowledge in the OC language:

2. Protocols and classifications

The protocol in OC is well understood, that is, the interface type in Java, and for the classification, it may be more cumbersome to implement in Java, and there are limitations, he is to an existing class to add some new features, such as the system of the operation string of the class NSString, he did not verify the function of the mailbox, Then we can add a classification to NSString, write a check mailbox of this function, the subsequent use of NSString type can call this function directly, but in Java we know that the string class is final type, can not inherit, That's why this expansion is not possible.

3, KVC and KVO operation

These two features are considered to be a better function in OC, and there are corresponding functions in Java, but we need to write them manually, and there are no rules that are troublesome. In fact, these two operations are for the properties of OC operation, where KV is a value key value pair Key-value, and KVC is the attribute key value pair to encode (Coding), meaning that you can manipulate the property, such as the property name can be set to the value of the property, In Java you can use introspection or reflection mechanism to implement, because in Java the provisions of the property is, as long as there is a corresponding get and set methods are called attributes, and the property name is the GetXXX method of XXX and the specific property name is not related, but in OC property name is the property name we define , and the Get and set methods are automatically generated by the system. And the KVO operation is the key value of the property of the Observer (Observer), the function is to listen to the value of the property of a class change, the use is still very large, such as want to track the value of a property change state, and then do some of the specified event trigger, etc. In fact, this function is also possible in Java, but there is no such strong rules in Java, such as some people will define the property directly using the public type, and then do not define the get and set methods, so when invoking a property is certainly not observed, unless the memory is monitored. If there is a strong rule in Java, the property must be private, and then use must call the set and get method, we only need to add a listener callback in these two methods can also do KVO function.

4. Function of collection class

OC and Java are similar, some collection classes used very much, in OC like Nsarray and nsdirctionary used more, they are equivalent to the list in Java and the map structure, In OC It is also important to note that if the type does not have a mutable type is an immutable structure type, such as Nsarray array, he is not able to do the pruning operation, and the corresponding Nsmutablearray type can be, do not know why so design. Many of the subsequent types will be this rule.

5, Basic function class frame: founction

This framework is similar to the class functionality in the Lang and util packages in Java, and the function framework in OC includes basic functional classes, such as the collection class above, and commonly used NSNumber classes: mainly for manipulating data types; NSData class: Operation Date Type, Of course there is also a class of the originator of the NSObject class also in this framework

third, UI knowledge Overview

From this point of knowledge, we will formally start the iOS app writing function, the previous knowledge point is just the foundation. About UI Knowledge learning in iOS is much simpler than the UI in Android, which will not be described in detail, followed by a separate introduction, mainly on several aspects:

1, common commonly used controls in iOS Introduction: including display text control Uilabel, display picture control Uiimageview, display the Prompt box control uialertview, switch control Uiswitch, and these controls we know are all systematic, Because the iOS system's native controls are designed to be perfect, they are generally used directly, rather than as a system dialog box in Android, and in many cases new design

2, iOS Advanced View Introduction: Here mainly introduces two important functional controls: UITableView and Uiscrollview, where UITableView is the same as the ListView usage in Android, And Uiscrollview is similar to Android in ScrollView, but his function is much more powerful than ScrollView, in iOS to achieve paging, switch pages are used by this control, and in Android using Viewpager to do.

3, Custom View view Description: Whether it is Android development or iOS development, some of the system's controls sometimes do not meet our needs, then we need to customize some of the controls, custom controls and Android also very similar, after the iOS inherited UIView, Using the Cgcontextref class in the DrawRect method to draw a variety of graphics, we know in Android that it was drawn using canvas in OnDraw.

4, Controller Introduction: The controller in iOS is similar to the activity component in Android, can show view, have its own life cycle method, and the controller system provides two commonly used controllers: Uinavigationcontroller and Uitabbarcontroller, the use of these two controllers is uinavigationcontroller mainly used to manipulate the view of the navigation function, For example, from one page to another page, this controller is actually a stack function, enter the words with push operation, out of the time use pop function to achieve the specified page jump function, in Android more laborious also have to use intent to do startactivity operation. Another Uitabbarcontroller feature is mainly used for menu view switching functions, which must now be in the page, at the bottom of the four menu switching function. Of course we can also customize a controller function.

5. Description of the event function of the view control: Android We know that there are a lot of events that require special handling, such as the slide down of the ListView, the left and right slide of the Viewpager, and so on iOS, some special needs to deal with the event.

four, multi-threaded operation

Multithreading in iOS is easier than threading in Java because he has fewer APIs, mostly four points of knowledge:

1. Custom thread Nsthread class, similar to the thread class in Java

2. Task class Nsoperation, similar to the Runnable class in Java

3. Task Queue class Nsoperationqueue, similar to the queue class in Java concurrency Library

4, gcd function, this function is mainly C language implementation, his advantage can re-use the device's multi-core hardware resources, so that multi-threaded operation more efficient, but also Apple's official advocate use of a way

Fifth, data local storage

iOS development sometimes want to save some data to the local, each application has its own sandbox structure, which is similar to Android, only the application has permission to operate, the data storage in Android mainly include: sharedpreference, database, SD card and so on. In iOS, the main points include the following:

1, Plist: You can generally save the array and dictionary data objects to the local Plist file.
2, Preference: Save the user's basic settings, and Android in the sharedpreference similar.
3, Nskeyedarchiver: Archive and file, you can serialize the object, and Java in the ObjectInputStream similar.
4, SQLite: Database operation, and Android in the bottom of the database used is the same, but here is the use of pure C language implementation.
5, coredata:orm operation, you can connect the object and database table operation.

vi, network access function

Any mobile platform is essential is the network access features, in Android with more than the HttpClient class, in iOS has similar to some system-provided network access API used, mainly related to these classes:

1. Nsurl: Defines the URL address of a network access.
2, Nsurlrequest: Network access Request object, you can set the parameter settings of the request.
3, Nsurlconnection: Direct connection access, the system automatically creates a child thread to operate.
4, UIWebView: This and Android WebView very similar, can access the content of the Web page, but he and Android WebView there are some differences.

Whether people recall the Android WebView a classic flaw is that in JS can use GetClass to get to object class object, and then call the runtime Class execution command to obtain device data information, This is because you can use the Addjavascriptinterface method to set up local objects in Android, not in iOS, if you want to invoke the local method in JS to think of a different way.

seventh, the introduction of commonly used frameworks in development

Whether it is the Android or iOS platform, in the actual development process only rely on the system to provide the functionality of the API will often not achieve the function we want, and efficiency is not so high, then some mainstream development framework appears, generally mainly related to the framework is network access, picture loading, drop-down refresh control, Database operations, and so on, in Android, these features have a well-known framework: Xutils. Using this framework can speed up an app, a lot of features easy to use. The same is true of some of the mainstream development frameworks in iOS, mainly in the following modules:

1. Network Access framework: afnetworking
2, the network picture loading frame: sdwebimage
3. List drop-down refresh frame: Mjrefresh
4. Database Operation framework: FMDB
5. UIWebView and local interaction framework: Webviewjavascriptbridge
6. Data Cache Framework: Yykit

eighth, practice project Walkthrough

The above is the development of technical points, and often in the real use of these points, you must rely on a number of practical projects to carry out the actual combat, so as to meet more problems to solve, understand more at the same time some of the functions will be more skilled, the practice here is mainly two: Weibo homepage implementation, naïve non-harmonic application.


This article is just about the general learning route of iOS, there is a general perception, the iOS learning has a warm-up, follow-up will be through these aspects of detailed introduction, or that sentence, code is not to see, is by hand knock out, experience is not by mouth to say out, is by hand knock out! Be sure to write more code more practice, think not all difficult.

Click here for more information:

Focus on the public, the latest technology dry real-time push

iOS Fury Trail (START)---learning route summary

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.