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