Threading or Notification problem...
Threading or Notification problem...
- Subject: Threading or Notification problem...
- From: Jeff LaMarche <email@hidden>
- Date: Wed, 24 Oct 2001 23:44:39 -0700
Okay, I've got a piece of code that works fine, even if several threads
are spawned.
However, I added in some notifications to a controller that keeps track
of the progress of the threads, and I'm getting an error that I can't
quite figure out. It's an "EXC_BAD_ACCESS" signal, that appears to be
occuring in CFStringFindWithOptions, and it happens even if there's only
one thread spawned.
The code that it's happening on is:
startLooking.location = startAt;
startLooking.length = [rawHTML length] - startAt;
// Find the next image result tag
// -------------------------------
tagStart = [rawHTML rangeOfString:@"<a href=/imgres"
options:NSCaseInsensitiveSearch
range:startLooking];
Now, I've made 100% sure that rawHTML object is not nil and that it
hasn't been released and isn't being used anywhere else. I tried
replacing the string literal with a string object and the result was the
same.
If I comment out the following line of code ('center' is a reference to
the default notification center, and is valid):
center postNotificationName:NKDUpdateStatus
object:nil
userInfo:[NSDictionary
dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:thisThread],
@"Thread ID", [NSNumber
numberWithInt:temp], @"Thread Progress", nil]];
the code above works fine. The bizarre thing is that this line of code
that is commented out doesn't fire until after the code where the error
is occurring! This code is not getting reached, yet commenting it out
resolves the problem.
I'm hornswaggled. Anyone have an idea what I'm overlooking here?