下面的代碼:如何使performSelector:withObject:afterDelay工作?
-(void)setProjectID:(NSString *)newProject {
[self willChangeValueForKey:@"projectID"];
[projectID release];
projectID = [newProject copy];
[self didChangeValueForKey:@"projectID"];
// Since we have an ID, now we need to load it
NSInvocation *returnInvocation = [NSInvocation invocationWithMethodSignature:
[Detail instanceMethodSignatureForSelector:@selector(configureView:)]];
[returnInvocation setTarget:self];
[returnInvocation performSelector:@selector(displayAlert) withObject:nil afterDelay:0.5];
[returnInvocation setSelector:@selector(configureView:)];
[returnInvocation retainArguments];
fetch = [[WBWDocumentFetcher alloc] init];
[fetch retrieveDocument:[NSURL wb_URLForTabType:PROJECT_DETAILS inProject:projectID] returnBy:returnInvocation];
}
-(void)displayAlert
{
UIAlertView * alert = [[UIAlertView alloc]
initWithTitle:@"Connection Error"
message:@"Error loading Data."
delegate:self cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
}
該應用程序崩潰說NSInvalidArguementException。 - [NSInvocation displayAlert]:無法識別的選擇器發送到實例0x5842320 請幫忙!!!
仍然崩潰,並且它給出警告NSInvocation可能不會響應太performSelectpr:afterDelay – Ashutosh
@ashutosh見上面 – PengOne