0

我正在使用ASI HTTP 请求执行异步请求,我想用请求中的新信息更新文本框,所以我从回调函数更新它。到目前为止,这是我的代码:

二等舱

- (void)Login {
    NSLog(@"Login");
    NSURL *url = [NSURL URLWithString:@"http://ts5.travian.sk/login.php"];
    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
    [request setDelegate:self];
    [request setDidFinishSelector:@selector(loginRequestFinished:)];
    [request setDidFailSelector:@selector(loginRequestFailed:)];
    [request startAsynchronous];
}

- (void)loginRequestFinished:(ASIHTTPRequest *)request
{
    NSLog(@"Completed!");
    NSString *response = [request responseString];
    AppController *ac = [AppController getInstance];
    [ac.textbox performSelectorOnMainThread:@selector(setStringValue:) withObject:response waitUntilDone:NO];
}

AppController 是一个主类。从那里设置文本是有效的。但是这段代码没有做任何事情。它只是将 2 条日志行写入调试窗口。

我错过了什么吗?

4

0 回答 0