我有以下代码:
- (void)imageDownloaded:(ASIHTTPRequest *) request idDisco:(NSNumber *)iddisco
NSLog(@"%d",[idPlace intValue]);
}
并且
NSURL *url = [NSURL URLWithString:[item objectForKey:@"image"]];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDelegate:self];
[request setDidFinishSelector:[self performSelector:@selector(imageDownloaded:idDisco:)withObject:request withObject:disco.id_disco]];
但编译器告诉我“从不兼容的pointe类型传递setDidFinishSelector的参数1”
它工作正常,但我不知道我做错了什么。
由于
答案 0 :(得分:2)
你必须在那里传递@selector(someMethod :): 并且方法的签名应该是
- (void)methodName:(ASIHTTPRequest *)request;
看看这个例子:
- (IBAction)grabURLInTheBackground:(id)sender
{
if (![self queue]) {
[self setQueue:[[[NSOperationQueue alloc] init] autorelease]];
}
NSURL *url = [NSURL URLWithString:@"http://allseeing-i.com"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDelegate:self];
[request setDidFinishSelector:@selector(requestDone:)];
[request setDidFailSelector:@selector(requestWentWrong:)];
[[self queue] addOperation:request]; //queue is an NSOperationQueue
}
- (void)requestDone:(ASIHTTPRequest *)request
{
NSString *response = [request responseString];
}
- (void)requestWentWrong:(ASIHTTPRequest *)request
{
NSError *error = [request error];
}