(reprint)---Overview of OC Learning articles

Source: Internet
Author: User
Tags new set

Preface

Finally opened the study of OC, before because of work, learning has been stranded, but recently for various reasons, feel must open iOS development journey, or old. Because it has been done Android, so learning iOS is not so hard, of course, we know that Android is supported by the Java language, iOS is OC-supported, about OC learning, and Java relative to this, so the efficiency will be higher, while in the University of C/s So, learning OC is no difficulty, it is a new set of APIs.

Overview

At present, Objective-c (OC) is the core language of iOS development, in the development process will also cooperate with the use of C language, C++,OC mainly responsible for the UI interface, C, C + + can be used for graphics processing. Recently, Ruby, C # can also develop iOS apps, even though Ruby is more suited to writing iOS programs than OC. This makes a lot of learning iOS development friends feel very troubled, which language is good to learn? Will OC be replaced by Ruby and C #? If it is replaced, then my OC is not a white school? Let me post a personal opinion:

1> Ruby, C # can also do iOS development, I think this is not a bad thing, can let more people in the field of iOS development, the collection of more Programs ape wisdom, create a few bright, epoch-making significance of the app, and then enrich AppStore, promote the development of iOS, the benefit of consumers.
2> OC The language has been maintained by Apple, Apple chose OC as the language of development of iOS, it must be justified, which also shows Apple's affirmation of OC. From the iphone's success it can be seen that Apple chose OC is right. Therefore, I think it is not possible for OC to be replaced by other languages.
3> 10,000 step back, if OC really was replaced by Ruby, I think this is not a fatal blow to experienced OC developers. Impossible because OC was eliminated, the majority of OC developers have no way to mix in the software industry. OC as an object-oriented language, its programming ideas and other object-oriented language are similar, but the grammatical characteristics are different. Therefore, you will never suffer after you learn OC, and later want to learn other languages is very fast, because the idea is the same. For example, you have been driving a Toyota car, one day Toyota closed, your car is rotten, can you give a BMW, you will not open it?
4> Therefore, I still recommend that you want to learn iOS development friends, sink down to learn oc well!

Introduction to Grammar

C language is a process-oriented language, OC is based on the C language, adding a layer of the smallest object-oriented syntax, why is the smallest object-oriented syntax? Because OC removes some of the more complex object-oriented syntax, and the rest is the object-oriented essence, OC is an object-oriented language and is much simpler than C + +. Because OC is C-based, it is fully compatible with the C language, which means that in the process of developing an iOS program, we can mix C code, even C + + code, in the OC code.

In Java, you can put these 2 classes in different packages in order to prevent two class names from having the same class conflicts. In OC, there is no concept of "package", that is, there is no namespace mechanism, instead of the developer to prefix the class name, using the prefix can effectively prevent the class name conflict. For example, NSString (the String class in OC), Nsarray (an array class of OC), their prefixes are NS
1> I said earlier, the OC code can be mixed with C language, C + + code, and C and C + + as a programming language, have their own keywords. to prevent conflicts with the C language and C + + keywords, the OC keyword begins with @.

Here are some common keywords, take a look at the line, do not go through the data to find their meaning, when used I will explain

1 @interface,@implementation,@end  2 @public、@protected、@private, @selector3 @try、@catch、@throw、@finally   4 @protocol,@class  5   6 //The new keywords introduced in OC 2.0 have7@property,@synthesize  8@optional, @required, @dynamic
2> Even strings are preceded by @, such as @ "Hello" is a string in OC, and "Hello" is a string in C language.

Summarize

Basic data types char, int, float, double, BOOL (yes\no)
Nil Equivalent to NULL
Self Equivalent to this in Java
Basic statement Do while, when, for, if, if else, switch, goto
For Loop fast traversal For (...)
Base class NSObject
Inherited Single inheritance, calling the parent class method with the Super keyword
Comments and/*...*/
Log output

NSLog (@ "Hello");

NSLog (@ "Age is%i", 27);

(reprint)---Overview of OC Learning articles

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.