OC learning --- overview, oc --- Overview

Source: Internet
Author: User

OC learning --- overview, oc --- Overview
Preface

I finally started the OC learning article. I had been stranded for work, but recently, for various reasons, I felt that I had to start the iOS development journey, otherwise it will be old. Because we have been working on Android before, it is not so hard to learn iOS. Of course, we know that Android is supported by Java and iOS is supported by OC, compared with Java, the efficiency will also be high. At the same time, I learned C/C ++ in college, so it is no longer difficult to learn OC, just a new set of APIs.


Overview

Currently, Objective-C (OC) is the core language for iOS development. It also works with C and C ++ during the development process. OC is mainly responsible for UI interfaces, C language and C ++ can be used for graphic processing. Recently, Ruby and C # can be used to develop iOS applications, and even Ruby is more suitable for iOS programs than OC. This has plagued many iOS developers. Which language is better? Will OC be replaced by Ruby and C? If I have been replaced, isn't my OC Bai Xue? I will share my personal opinion below:

1> Ruby and C # can also be used for iOS development. I don't think this is a bad thing. It allows people in more fields to invest in iOS development and brings together the wisdom of more programmers, create more eye-catching and epoch-making apps, enrich AppStore, promote iOS development, and benefit consumers.
2> the language OC has been maintained by Apple. Apple chose OC as the iOS development language for some reason, which also demonstrates Apple's recognition of OC. From the iPhone's success, we can also see that Apple's choice of OC is correct. Therefore, I think it is impossible to replace OC with other languages.
3> Step 4: If the OC is replaced by Ruby, I think this is not a fatal blow to experienced OC developers. It is impossible for the majority of OC developers to mix up in the software industry because the OC has been eliminated. As an object-oriented language, OC's programming philosophy is similar to that of other object-oriented languages, but its syntax features are different. Therefore, after you have learned OC, you will never suffer. If you want to learn other languages in the future, it will be very fast, because the idea is the same. For example, you used to drive a Toyota car all the time ago. One day, Toyota collapsed and your car crashed. Could you just give you a BMW and you wouldn't drive it?
4> therefore, I suggest those who want to learn about iOS development. Let's learn the OC!


Syntax Overview

C language is a process-oriented language. OC adds the smallest object-oriented syntax based on C language. Why is it the smallest object-oriented syntax? Because OC removes some complex object-oriented syntaxes and the rest are the essence of object-oriented, OC is an object-oriented language, which is much simpler than C ++. Because the OC is based on the C language, it is fully compatible with the C language. That is to say, we can mix the C language code into the OC code During iOS program development, or even the C ++ code.

In Java, to prevent conflicts between classes with the same class names, you can place these two classes in different packages. There is no "package" concept in OC, that is, there is no namespace mechanism. Instead, developers Add a prefix to the class name, which effectively prevents class name conflicts. For example, NSString (string class in OC) and NSArray (array class in OC), whose prefixes are NS
1> As I mentioned earlier, OC code can be mixed into C and C ++ code, while C and C ++ both have their own keywords as a programming language. To prevent conflicts with the C language and C ++ keywords, the OC keywords all start.

The following lists some common keywords. You just need to take a look at them. You don't have to go over the information to find out their meanings. I will explain them later.

@ Interface, @ implementation, @ end @ public, @ protected, @ private, @ selector @ try, @ catch, @ throw, @ finally @ protocol, @ class // The New keywords introduced in OC 2.0 include @ property, @ synthesize @ optional, @ required, @ dynamic
2> even strings start with @. For example, @ "Hello" is a string in OC, while "Hello" is a string in C.

Summary




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.