Objective-C Overview

Source: Internet
Author: User

Preface

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!

 

I. Introduction 1. C Language

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.

 

2. Role

We can use OC to develop Mac OS X and iOS applications.

Here is a brief description of Mac OS X and IOs:

  • Mac OS X is the exclusive operating system developed by Apple for Mac products. Currently, the operating system is equipped with devices such as MacBook, iMac, and Mac Mini.
  • IOS is a handheld device operating system developed by Apple. Currently, devices equipped with this operating system include iPhone, iPad, iPod Touch, and iPad Mini.

 

3. Popularity

Below is the top ranking of programming languages in March 2014

Ii. Syntax preview 1. No package name (namespace) Concept

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

 

2. All keywords start @

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.

 

3. Key Points of syntax

Related Article

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.