Objective-c (XCODE7) new features

Source: Internet
Author: User

    • nullability

The nullability attribute is used to indicate whether the pointer can be nil, and the intent of the API can be expressed more clearly by this feature.

At the same time, the compiler nullability the code at compile time, prompting the necessary warnings.

To be added to Ns_assume_nonnull_begin when using ... Between Ns_assume_nonnull_end

Object pointers: Nullable nonnull

C-pointer: __nonnull __nullable __null_unspecified

Null_resettable is used in attributes, the setter method that represents the property can be set to the Nil,getter method and does not return nil


    • Lightweight generics

Lightweight is because this is a pure compiler syntax support (LLVM 7.0), like nullability, without any OBJC runtime upgrades, that is, this new syntax can be used on Xcode 7 and fully backwards compatible (lower IOS version)

Mainly used in Nsarray and nsdictionary containers.

An array object that holds only the string object:

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/7C/7E/wKioL1bRn4ijVQEjAAB4X-xuiyA648.png "title=" screen shot 2016-02-27 pm 9.05.04.png "width=" 598 "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:598px;height:80px; " alt= "Wkiol1brn4ijvqejaab4x-xuiya648.png"/>

A Dictionary object that only exists for numeric objects:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/7C/7F/wKiom1bRnzuTsm1OAAFmkZMcwFw516.png "title=" screen shot 2016-02-27 pm 9.05.42.png "width=" 598 "height=" 107 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:598PX;HEIGHT:107PX; " alt= "Wkiom1brnzutsm1oaafmkzmcwfw516.png"/>

To customize a container that supports generics:

@interface Stack <StackType>: nsobject-(void) Pushobject: (Stacktype) obj;-(stacktype) popobject; @end


    • __kindof

Such as:

__kindof Amperson * p;

Object used to indicate that the pointer is storing a Amperson object or a Amperson subclass

Resolves problems with poor readability before using ID types, and adds legitimacy validation



This article is from the "Teacheran" blog, make sure to keep this source http://annmeng.blog.51cto.com/3321237/1745638

Objective-c (XCODE7) new features

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.