I have a strange problem. I am using a method from Apple's private private applications in my application. When I call it the first time, it works. When I call him a second time immediately, without anything in between, he falls. However, if I installed NSLog between two calls, it works fine. So I'm trying to remove NSLog and put for-loops, sleep (), printf ("...") and fprintf (stderr, "...") between them to emulate NSLog, but that does not help. I am wondering how the method knows that I am using NSLog? In other words, what does NSLog actually do to influence the behavior of a method?
Many thanks!
EDIT:
I seem to have solved this problem. I will share my decision here and hope it can be useful for some people.
I am creating a multitouch application using MultitouchSupport.framework. I copied the code from http://aladino.dmi.unict.it/?a=multitouch and added CFReleaseat the end of the loop. So basically, my main method is as follows:
int main(void) {
int i;
NSMutableArray* deviceList = (NSMutableArray*)MTDeviceCreateList();
for(i = 0; i<[deviceList count]; i++) {
MTRegisterContactFrameCallback([deviceList objectAtIndex:i], touchCallback);
MTDeviceStart([deviceList objectAtIndex:i], 0);
}
CFRelease((CFMutableArrayRef)deviceList);
printf("Ctrl-C to abort\n");
sleep(-1);
return 0;
}
After starting up, "Software received signal:" EXC_BAD_ACCESS "will be displayed for a while." And here is the stack trace:
#0 0x7fff8795496e in ParsedMultitouchFrameRepInitialize
#1 0x7fff879565b1 in mt_HandleMultitouchFrame
#2 0x7fff87955a03 in mt_DequeueDataFromDriver
#3 0x7fff87955b29 in mt_DequeueMultitouchDataFromDriverThreadEntry
#4 0x7fff831b3456 in _pthread_start
#5 0x7fff831b3309 in thread_start
However, if I put the NSLog below MTDeviceStart, it will not work.
The reason I added CFRelease((CFMutableArrayRef)deviceList)to the source code is because I think that objects created from functions named * Create * or * Copy * must be released by themselves. But it turns out that if I delete it, as the source code does, it will not work, even without using NSLog.
, , deviceList ? , NSLog, , ?