COCOSD Error in imp call on Xcode7 and iOS 9.2

Source: Internet
Author: User

Panda Pig • Patty original or translated works. Welcome reprint, Reprint please indicate the source.
If you feel that the writing is not good please more advice, if you feel good please support a lot of praise. Thank you! Hopy;)

The original code has been running on Xcode6.4 and iOS 8.4, and there's nothing wrong with it.

However, after running on iOS9.2 on Xcode7.2, an error occurs in the following methods:

//执行一个可变方法-(id)invokeSelectorNamed:(NSString *)selectorName{    SEL selector = NSSelectorFromString(selectorName);    IMP imp = [self methodForSelector:selector];    id (*func)(id,SEL) = (void*)imp;    return func(_gameScene.curMapNode,selector);}

The error type is i386 Universal protection error.

There are several places in the project that call the above methods, and the incoming selectorname are different. Later debugging found that only some selector calls would go wrong, while others never went wrong.

Carefully examine the selector code for the error, and find that the code does not return a value, whereas the Func prototype is the return value.

This shows that in Xcode7.2 the IMP call is checked, the function prototype is inconsistent, even if the return value is inconsistent, the call will go wrong.

Knowing the cause of the problem is simple enough to make each function prototype consistent, even if you return nil:

(NSString*)someFunc{    //原代码    returnnil;}

COCOSD Error in imp call on Xcode7 and iOS 9.2

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.