There is a task needs to draw N images on a NSView. But at the beginning I do not know the amount of images, so I set it works in a thread of background.
[NSThread detachNewThreadSelector:@selector(workInBackgroundThread:) toTarget:self withObject:nil];
when it get the amount of images, it will send a notification
- (void)workInBackgroundThread:(id)unusedObject {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
//get image amount....
[[NSNotificationCenter defaultCenter] postNotificationName:@"gotImageAmount" object:nil];
//...
//continue to load images
}
I try to resize the NSView depends on the amount of images in the notification function
-(void)processGotImagesAmount:(NSNotification*)notification
{
//others codes
[myNSView setFrame:CGRectMake(0, 0, calculateNewWidth, caculatedNewHeight)];//line A
//others codes
}
but when the app executes the line A, it freezes,
[myNSView setFrame:CGRectMake(0, 0, calculateNewWidth, caculatedNewHeight)];
itself has no problem, if I click a bottun to call it, it works!
but it looks like it does not work in a notification function
Welcome any comment