The method run by the thread needs to write to a location that the objects that care about the result would have access to. One solution would be to have a method wrap the call, get the result, and post a notification that includes the result in the user info. Objects that care can then handle the notification. Note that the objects must be created before the thread is started, otherwise the object might miss the notification.
A sketch of the solution is:
#define kDropletAvailabilityNotificationName @"com.myapp.notifications.DropletAvailability"
@implementation MyObject
- (void)registerNotifications {
[[NSNotificationCenter defaultCenter]
addObserver:self selector:@selector(dropletAvailabilityNotification:)
name:kDropletAvailaibiltyNotificationName
object:nil];
}
- (void)unregisterNotifications {
[[NSNotificationCenter defaultCenter]
removeObserver:self];
}
- (void)dropletAvailabilityNotification:(NSNotification *)note {
NSNumber *boolNum = [note object];
BOOL isAvailable = [boolNum boolValue];
/* do something with isAvailable */
}
- (id)init {
/* set up… */
[self registerNotifications];
return self;
}
- (void)dealloc {
[self unregisterNotifications];
/* tear down… */
[super dealloc];
}
@end
@implementation CheckerObject
- (rsotine)arositen {
/* MyObject must be created before now! */
[self performSelectorInBackground:@selector(checkDropletAvailability) withObject:nil];
}
- (void)checkDropletAvailability {
id pool = [[NSAutoreleasePool alloc] init];
BOOL isAvailable = [self backupDropletUpdateAvailable];
NSNumber *boolNum = [NSNumber numberWithBool:isAvailable];
[[NSNotificationCenter defaultCenter]
postNotificationName:kDropletAvailaibiltyNotificationName
object:boolNum];
[pool drain];
}