IOS extern Use tutorial

Source: Internet
Author: User

Demo Download http://download.csdn.net/detail/u013375242/8335911

Don't talk nonsense, iOS development, with Xcode, project structure as follows:


1. Define the My_extern class, inherit the NSObject,

. m file as follows

.:

2. The Viewcontroller call, without introducing the header file on the class, is used directly in ViewController.h: The following:





extern usage Explanation

Variables defined in the source file A are invisible (i.e. inaccessible) in other source files. In order to call this function in the source file B, an external declaration should be added to the head of B:
extern variable;

in this way, the variable can also be called in the source file B.

Note the word difference here: In A is the definition, in B is the statement. A function can only (and must) be defined in one source file, but it can be declared in many other source files. The definition causes the storage allocation to actually produce that entity. Declarations do not cause storage allocations. Make a vulgar analogy: after declaring it in the source file B, it's like opening a window in B, so that it can see the variable in a.


IOS extern Use tutorial

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.