NSViewにN個の画像を描画するタスクがあります。 しかし、私はイメージの量を知らないので、私はそれをバックグラウンドのスレッドで動作するように設定しました。バックグラウンドスレッドの更新に関する通知NSView
[NSThread detachNewThreadSelector:@selector(workInBackgroundThread:) toTarget:self withObject:nil];
それは画像の量を得るとき、それは私がNSViewの通知機能
-(void)processGotImagesAmount:(NSNotification*)notification
{
//others codes
[myNSView setFrame:CGRectMake(0, 0, calculateNewWidth, caculatedNewHeight)];//line A
//others codes
}
の画像の量に依存してサイズを変更しようとする通知
- (void)workInBackgroundThread:(id)unusedObject {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
//get image amount....
[[NSNotificationCenter defaultCenter] postNotificationName:@"gotImageAmount" object:nil];
//...
//continue to load images
}
を送信しますアプリがラインAを実行するとフリーズします。
[myNSView setFrame:CGRectMake(0, 0, calculateNewWidth, caculatedNewHeight)];
それ自体は問題なく、私はそれを呼び出すためにボトルをクリックすると、動作します!
が、それは、通知機能に
を動作しないように見えますがあなたがバックグラウンドスレッドから通知を投稿している任意のコメント