"C # my sister and Aunt Objective-C" (01) meet Objective-C: greetings from the first meeting

Source: Internet
Author: User

Aunt Objective-C:C # Hello, little sister!

# Import <Foundation/Foundation. h> int main (int argc, const char * argv []) {NSLog (@ "C # Hello, little sister! "); Return 0 ;}

C # sister:Aunt Objective-C!

Using System; namespace CSharpToObjectiveC {class Program {static void Main (string [] args) {Console. WriteLine ("Objective-C aunt! ");}}}
C # sister:Aunt, you see our code is very similar. Aunt Objective-C:Yes, we are all relatives of C language, including C ++ and Java. They all blame Grandpa C for being too competent and widely used. In order to facilitate people to learn, many of the following languages are developed on the basis of C. However, I still have a big difference with you in terms of lineage. I am an extension of C language, or an enhancement. I have all my grandfather's set of things. I do not need to modify the original C language at all, I can compile and run it, but you can't. You just look like it. It is easier to learn than C ++.
C # sister:In this case, # import <Foundation/Foundation. h> is this statement imported into the namespace? My brother VB. NET seems to use import to import the namespace, but I use the using statement.

Aunt Objective-C:Aunt does not have the namespace statement or similar functions. This statement tells the compiler to query the definition in the header file. It is more like adding a reference function.
C # sister:So how can we avoid class name conflicts? Aunt Objective-C:It's easy. You should have read my NSLog () function, which was originally called Log. But to demonstrate that it is a function provided by Cocoa, an NS is added to the front. C # sister:Dizzy. Isn't the code messy? Why is the function provided by Cocoa a prefix of NS? Aunt Objective-C:This is what you get used. NS is a historical issue. Cocoa was originally called NextStep, short for NS. Later, NextStep was acquired by Apple, but the programming style has never been changed. In fact, NextStep has a lot to do with Apple. After Steve Jobs was dismissed by Apple in 85 years, he set up a new company and used me to develop NextStep. Later, Apple's performance declined along the way, and he found that it was not good if Steve Jobs was missing, in 96 years, Steve Jobs was sold together with the company's products and people ...... You were not born yet... C # sister:It sounds so tangled... Aunt Objective-C:Yes, today's children are so happy. You see, when you are born, you will be favored by everyone. Microsoft has spent a huge amount of money to build and promote it, and it has grown to 4.0 at a young age, however, aunt is thirty years old and only 2.0 years old. It is not as widely used as you do. Well done, it's better to be born. It's all life... if it weren't for Apple, it's estimated that you can only see in the wiki that I used C # sister:Come on, aunt. You are also amazing now. Aren't iPhone and iPad all developed by you? Look at the subway, there's a human hand, Ox. I have almost been defeated in the mobile Phone field, and now I am looking at Uncle Gates's Windows Phone. By the way, aunt, do you have no category? Aunt Objective-C:Yes, aunt is also an authentic object-oriented language. But like C ++, you and Java are not as thorough as they are. I still have a global method, such as the main and NSLog you see. After all, I still have C language in my bones and added object-oriented features. You have cleared all content that is not object-oriented. C # sister:I can guess the NSLog () statement. Is it a function with my Console. WriteLine? Aunt Objective-C:That's right, it's not just a console program. As long as you do Mac development, including iPhone \ iPad and NSLog (), you can easily monitor the status and process of the program. Compared with the C language printf (), NSLog () adds timestamps and line breaks, and also supports classes. C # sister:Does the @ at the front of the string indicate that the character strings in the backend cannot be escaped? Aunt Objective-C:It has no relationship with that. Here, @ indicates that the string is of the NSString type of Cocoa. C language has many primitive types, such as character arrays, but it is too troublesome to use. Therefore, Cocoa has extended a set of similar objects, such as NSString, NSNumber, and NAArray, features are greatly enhanced. In Objective-C development, these objects should also be used as much as possible. In addition, as a special symbol, as long as you see @ in the code, it means that Objective-C is extended here. C # sister:Aunt is really not easy. She made so many compromises to be fully compatible with the C language. Aunt Objective-C:Yes, thirty years ago, the C language came into being, and there was an urgent need for Object-Oriented Programming. Therefore, the combination of the two products became more acceptable. Life needs dreams, and life needs compromise...

-

Dear colleagues, it takes a short time to learn Objective-C. learning Objective-C is not for Mac or iPhone development, but not practical,
Actually, it is a C # Learning note for the user to learn Objective-C. The exact purpose of learning is to help me understand C #After all, it is impossible to know the characteristics of C # without comparison.
Please take a critical look at this.If it is found that there are conflicts with other articles, books, comments, and materials, please refer to other articles as far as possible. And leave me a message
I also invite all experts to make bricks actively. I just used it to build a house ~~~
C # dialogue between sister and Aunt Objective-C

(01) meet Objective-C: greetings from the first meeting
(02) This is an aunt's dog.
(03) NSString -- meet another dog
(04) Basis of garbage collection-about the demolition team

Pending renewal

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.