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!
First, Introduction1. 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.
2. Role
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.
Second, Syntax preview1. 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