问题描述
我在这里看到类似的问题,但是找不到我的问题的解决方案。我在主线程中有一个简单的NSURLConnection(至少我没有创建任何其他线程),但是我的委托方法没有被调用
[[NSURLConnection alloc] initWithRequest:request delegate:self] autorelease];
,没有方法调用,例如
<$ p $($)$($)$($)$($)$($)$($)
}
self
NSXMLParser的代表,但我认为这不应该是一个问题,因为我在同一个项目的其他类中工作。我已经检查过10次,但找不到任何问题。
我在这里看到一些黑客来解决:但我不喜欢,可能有人知道更好的解决方案?感谢
我知道的唯一原因是单独的线程(当委派方法被调用时已经终止) p>
尝试 NSLog(@Is%@ main thread,([NSThread isMainThread]?@:@NOT));
在创建链接连接之前
I saw similar questions here, but I couldn't find solution to my problem.I have a simple NSURLConnection in main thread (At least I didn't create any other threads), but my delegate methods aren't get called
[[[NSURLConnection alloc] initWithRequest:request delegate:self] autorelease];
and no methods called, e.g.
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
NSLog(@"didReceiveResponse");
}
self
is also a delegate for NSXMLParser, but I think it should not be a problem, as I have this working in my other class in the same project. I checked everything 10 times already, but can't find any problem.
I've seen some hack to solve it here: http://www.depl0y.com/?p=345 but I don't like it, May be someone knows better solution? thanks
The only reason I know is a separate thread (that is already terminated when the delegate methods are called).
Try to NSLog(@"Is%@ main thread", ([NSThread isMainThread] ? @"" : @" NOT"));
right before the url connection creation
这篇关于NSURLConnection不调用委托方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!