IOS _ attribute _ (warn_unused_result), attributeunused

Source: Internet
Author: User

IOS _ attribute _ (warn_unused_result), attributeunused

Original Blog. For more information, see the source.

Blog.csdn.net/hello_hwc


Meaning of this Keyword: If a function uses this keyword, the compiler will warn you when the function is called to check or use the return value.

Usage: When Encapsulating some functions (or compiling the SDK), if the use of the return value is important, use this keyword to remind the compiler to check whether the return value is used.

Example:

-(BOOL) TestFunc :( NSInteger) num _ attribute _ (warn_unused_result) {return num> 0? YES: NO ;}
If I call

[Self TestFunc: 10];

The compiler will give the following warning:


The warning disappears after the returned value is checked.

BOOL result = [self TestFunc: 10];

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.