2011-02-01 60 views
0

我有以下代碼:iPhone ASIHTTP setDidFinishSelector問題

- (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]]; 

但是,編譯器告訴我, 「傳遞參數1 setDidFinishSelector從不相容的足尖型」

它工作正常,但我不知道我做錯了什麼。

感謝

回答

2

你要通過@選擇(的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]; 
} 
+0

對不起,我編輯我的問題,因爲我需要一個有兩個參數的選擇器 – xger86x 2011-02-01 00:13:53