COCOS2DX 3.9.1 mac simulator log output bug fix

Source: Internet
Author: User

Today, there are cases where the Mac simulator does not output log, and traces the Handlenotification method of discovering the problem that appears in the mac/simulatorapp.mm file.

NSString *STR = [[[NSString Alloc] initwithdata:data encoding:nsutf8stringencoding] autorelease];

  

This code in some cases str will be nil value cause the simulator will not output any log, because the data encoding in the existence of individual characters garbled results in the overall output of the case.

The modified code is as follows

-(void) Handlenotification: (nsnotification *) note{    //nslog (@ "Received notification:%@", note);    [_pipereadhandle readinbackgroundandnotify];    NSData *data = [[Note UserInfo] objectforkey:nsfilehandlenotificationdataitem];    NSString *STR = [[[NSString Alloc] initwithdata:data encoding:nsutf8stringencoding] autorelease];    if (!str)    {        str =[[[nsstring alloc]initwithdata:data encoding:nsasciistringencoding] autorelease];    }    if (!str)    {        str = @ "encoding NSData to nsstring error";    }    Show log to console    [_consolecontroller trace:str];    if (_filehandle!=nil)    {        [_filehandle writedata:[str datausingencoding:nsutf8stringencoding];    }}

When using UTF8 to decode with the ASC decoding output, so that you can see the output

  

COCOS2DX 3.9.1 mac simulator log output bug fix

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.