I'm running up against an interesting problem that I've been unable to find a solution for. The below code dies when it reaches the string formatting line sptr = [NSString...] with an EXC_BAD_ACCESS signal. curFile and totalFiles are both set previously, I've even hardcoded them to various values, and tried various diffrent strings and the thread always dies at the first instance of [NSString stringWithFormat:#]. It dies in the same way if I use [[NSString alloc] initWithFormat:#].
Can anyone point me at something I'm doing wrong? (Garbage collection in enabled as FYI).
[EDIT 1:57pm PST]
A few additional pieces of information: If I call the function CreationThread directly instead of instantiating a new thread the code works as is, with no modification. curFile and TotalFiles are local to CreationThread. I've hardcoded both variables to 0 prior to the string formatting and it's still causing an EXEC_BAD_ACCESS signal.
Nixing the multithreading isn't really a desirable solution. Thus the post.
Can anyone point me at something I'm doing wrong? (Garbage collection in enabled as FYI).
Code:
<On a button push>
[NSThread detachNewThreadSelector:@selector(CreationThread) toTarget:self withObject:nil];
- (void) CreationThread
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
.
.
.
NSString *sptr = [NSString stringWithFormat:@"%i of %i", curFile, totalFiles];
[progressLabel setStringValue:sptr];
sptr = nil;
.
.
.
[pool drain]
}
[EDIT 1:57pm PST]
A few additional pieces of information: If I call the function CreationThread directly instead of instantiating a new thread the code works as is, with no modification. curFile and TotalFiles are local to CreationThread. I've hardcoded both variables to 0 prior to the string formatting and it's still causing an EXEC_BAD_ACCESS signal.
Nixing the multithreading isn't really a desirable solution. Thus the post.
Last edited: