Iphone Development Study Note 2

Source: Internet
Author: User

The development environment for Mac OS and iphone is mainly XCode and Interface Builder. Before XCode 3.0, XCode and Interface Builder were two relatively independent applications. One was mainly used to write code, the Interface Builder is mainly used to design the user Interface. It has been integrated into XCode since XCode 4.0.
Let's talk about Objective C, the development language used for Mac OS and iphone development. Here we don't want to compare Objective C with Objective C # and Java. Different people have different ideas. According to Apple's documentation, one of the biggest features of Objective C is Dynamic performance, Dynamic Message Dispacth, Dynamic Binding, and so on.
Here, developers familiar with C ++, Java, and C # are reminded that Objective C is also an object-oriented programming language, but it is very different from its cousin C ++, and larger programs are more like C languages.
1. Objective C still uses a lot of pointers, and in many cases it is necessary to manually manage the memory. Although Garbage collector is provided on Mac OS, It is not supported on iphone. Even if Garbage collector is supported in the future, Apple still recommends using mobile phones to manage memory for a more effective reason. This may disagree with people who previously used automatic memory management such as Java and C #. After all, manual memory management is cumbersome and may cause memory leakage. The increasingly powerful hardware functions can completely make up for the efficiency problems caused by automatic memory management.
2. Objective C strictly speaking, there is no Constructor, but it is customary to use the method (Message) Starting with init as the Constructor. Dealloc is the destructor. Used to release memory (often used to release class variables ).
3. The Objective C method is called message, which is also a notable credential of Objective C. If you see a code with a similar
The [object message] Code can basically determine that this is an Objective C code.
The same Code is in Java
Int age = person. getAge ();
In Objective C
NSInteger age = [person getAge];
If parameters are included, the syntax of Objective C is not used to the beginning :-).
4. Objective C does not have the Namespace concept. To avoid naming conflicts, prefixes such as NSString and NS are generally used. You can use the function or company name abbreviation as the prefix.
5. For code comments, Objective C generally uses Docxgen to generate code documents.
6. cocoa and Cocoa Touch provide the Foundation Framework, AppKit, and UIKit interfaces that use Objective C object-oriented object interfaces. However, a considerable number of Apis still use C interfaces, such as the Quatz 2D graphics library. For example, I plan to find the Math class similar to the Java library in Objectivc C, but I haven't found it for a while. Google, I still use math. h like C 10 years ago :-)
Finally, I used the line "When in Colletive, adapt" in Star trek voyager to adapt to Objective C if I want to develop an iphone or Mac application. After a long time, I got used to it. In addition, basically all object-oriented concepts in Java are also supported by Objective C, but implemented in different ways.
Apple's documents and tutorials are well written, which can also make up for some inconvenience in the development environment.

 


Excerpted from the mobile app

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.