Mix C or C ++ code into Object-C code in XCode

Source: Internet
Author: User

This question is not well written and I feel helpless.

Object-C is actually a language for embedding runtime-level Object calls in C or C ++ code!

 

What is a running-level object call, that is, an object call is not at the syntax level, but at the runtime level after compilation. Similar technologies include Microsoft's COM and open Object Organization's Corba, however, the last two do not add the calling content of the running-level object to the implementation language, but use separate IDL syntax and files!

 

After understanding the above, we can understand that the compiler should regard the source file as C or C ++ for compilation!

Method 1: directly change the extension

The. m file is to compile the source file as a C file written with Object-C.

The. mm file is to compile the source file as a C ++ file written with Object-C.

 

Method 2: Use Xcode to change the file attributes

Select a file and open Filey-> Get Info of Menu.

Change the drop-down selection of File Type. I believe the programmer can see at a glance what it means :)

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.