爲什麼我得到這個代碼的「wait_fences:無法接收回復」?這是我使用通知返回主線程的方式嗎?爲什麼我得到這個代碼的「wait_fences:未能收到回覆」?
#import "ViewController.h"
@implementation ViewController
@synthesize alert;
#pragma mark - Background Thread Test Methods
- (void) ConfigTasksForBackground:(id)sender{
NSLog(@"ConfigTasksForBackground - Starting");
[NSThread sleepForTimeInterval:6];
[[NSNotificationCenter defaultCenter] postNotificationName:@"ModelChanged" object:self];
NSLog(@"ConfigTasksForBackground - Ending");
}
#pragma mark - Callbacks
- (void) ModelChangedHandler:(NSNotification *) notification {
if ([[notification name] isEqualToString:@"ModelChanged"]) {
NSLog(@"ModelChangedHandler");
[self.alert dismissWithClickedButtonIndex:0 animated:false];
}
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(ModelChangedHandler:)
name:@"ModelChanged"
object:nil];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
self.alert = [[[UIAlertView alloc] initWithTitle:@"Title"
message:@"viewDidAppear"
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:nil] autorelease];
[alert show];
[self performSelectorInBackground:@selector(ConfigTasksForBackground:) withObject:nil];
}
@end
輸出是:
2011-11-07 15:15:42.730 test_background[6876:13603] ConfigTasksForBackground - Starting
2011-11-07 15:15:48.734 test_background[6876:13603] ModelChangedHandler
2011-11-07 15:15:49.236 test_background[6876:13603] ConfigTasksForBackground - Ending
wait_fences: failed to receive reply: 10004003
檢查SO帖子... http://stackoverflow.com/questions/4241894/wait-fences-failed-to-receive-reply-10004003-error-uialert-without-uitextfie – Jhaliya
沒有修復它實際上 - 在觸發「ModelChangedHandler」後發生了wait_fences – Greg