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

Source: Internet
Author: User

Xiao Mo's children's shoes

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

View sourceprint? 1 # import <Foundation/Foundation. h>

2

3 int main (int argc, const char * argv [])

4 {

5 NSLog (@ "C # Hello, little sister! ");

6 return 0;

7}

C # sister: Aunt Objective-C!

View sourceprint? 01 using System;

02

03 namespace CSharpToObjectiveC

04 {

05 class Program

06 {

07 static void Main (string [] args)

08 {

09 Console. WriteLine ("Objective-C aunt! ");

10}

11}

12}

C # sister: Aunt, you see our code is very similar.
Objective-C aunt: Yeah, we are all relatives of C language, including C ++ and Java. They all blame Grandpa C for being too competent and widely used, to make it easier for people to learn, many 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: Well, # 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.
Objective-C aunt: Aunt Yan 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: how can we avoid class name conflicts?
Objective-C aunt: Attention is very simple. You should have read my NSLog () function called Log, but to demonstrate that it is a function provided by Cocoa, a ns is added in front.
C # sister: dizzy. Isn't the code messy like this? Why is the function provided by Cocoa a prefix of NS?
Aunt Objective-C: Do you get used to this. 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: Wow, yes, how happy the children are now. You see, you get the favor of everyone when you were born. Microsoft spent huge sums of money to build and promote it, I have grown to 4.0 at a young age, but my aunt is thirty years old and only 2.0. 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: Don't be sad, 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?
Objective-C Ayi: she has, and she is also an authentic object-oriented language. But like C ++, she is not as thorough as you and Java are object-oriented. 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?
Objective-C aunt: That's right. It's not just a console program. As long as you do Mac development, including iPhone iPad and NSLog (), it's often used, so 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 are forcibly escaped?
Objective-C aunty: there is no relationship between struct and that. Here @ indicates that the string is 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 unified the world, and there was an urgent need for Object-Oriented Programming. Therefore, the combination of the two products made it easier to accept. 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 the so-called C # without comparison.
Please take a critical look at this. If you find 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
We also invite all experts to make a good shot.

 

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.