Objective-C attribute & package

Source: Internet
Author: User
Difficult to express original meaning in Chinese
Method and class attributes

Objective-C
Now supports some GCC attributes for objective-C methods.
Syntactically, attributes for a method follow the method's declaration,
And attributes for a method parameter sit between the parameter type and
The parameter name. Supported attributes include:

  • Deprecation and availability, including availabilitymacros. h

       - (void)method:(id)param  __attribute__((deprecated));
  • Unused Parameters

        - (void)method:(id) __attribute__((unused)) param;
  • Sentinel parameters, includingNS_REQUIRES_NIL_TERMINATION

        - (void)methodWithObjects:(id)obj, ...  NS_REQUIRES_NIL_TERMINATION;

Objective-C
Also supports some GCC attributes for objective-C classes.
Syntactically, attributes for a class precede the class's@interface
Declaration. Supported attributes include:

  • Deprecation and availability, including availabilitymacros. h

        __attribute__((deprecated))
        @interface MyDeprecatedClass : SomeSuperclass
  • Visibility

        __attribute__((visibility("hidden")))
        @interface MyPrivateClass : SomeSuperclass

@ Package instance variables

@package
Is a new instance variable protection class, like@public
And@protected
.@package
Instance variables behave as follows:

  • @public
    In 32-bit;

  • @public
    In 64-bit, inside the framework that defined the class;

  • @private
    In 64-bit, outside the framework that defined the class.

In 64-bit, the instance variable symbol for@package
Ivar is not exported, so any attempt to use the Ivar from outside
Framework that defined the class will fail with a link error. See "" 64-bit class and instance variable access control"

"For more about instance variable symbols.

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.