Overview of the "Objective-c" 01-objective-c

Source: Internet
Author: User

directory of this document
    • Objective
    • First, Introduction
    • Second, Syntax preview

Description: This objective-c topic is a prelude to learning iOS development, and to enable programmers with experience in object-oriented language development to quickly get started with objective-c. If you do not have programming experience, or are not interested in objective-c, iOS development, please ignore. Before studying this topic, it is recommended to study the C language topic first.

Back to the top of the preface

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!

Back to top one, Introduction 1. Based on C language

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.

1. Use

We can use OC to develop applications for Mac OS x platform and iOS platform.

Here's a brief description of Mac OS X and iOS:

    • Mac OS X is the exclusive operating system developed by Apple for the Mac family, and currently features the OS: MacBook, IMac, Mac Mini
    • iOS is a handheld operating system developed by Apple, which currently features the operating system: IPhone, ipad, IPod touch, ipad Mini

3. Heat

The following is the March 2013 popular leaderboard for programming languages

Compared to 2012, OC's heat rose by 2.

Back to top second, Syntax Preview 1. No concept of package name (namespace)

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

2. Keywords all start with @

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

@interface, @implementation, @end @public, @protected, @private, @selector @try, @catch, @throw, @finally @protocol, @ The new keywords introduced in class//OC 2.0 are @property, @synthesize @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.

3. Key points in grammar

Overview of the "Objective-c" 01-objective-c

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.