And implements the delegate methods, but it seems that those
methods are not called at all. I search the problem in stackOverflow for some time and find a blog(here) that helps me know and solve the issue. "If you are performing this on a background thread, the thread is
So I follow codes in that blog and modify code in my NSOperation object
to keep the runloop form exiting is to just put it in an infinite loop: - (void) start [NSURLRequest requestWithURL:download_.url cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:15] delegate:self]; if (connection_ != nil) { [self willChangeValueForKey:@"isExecuting"]; executing_ = YES; [self didChangeValueForKey:@"isExecuting"]; } else { [self willChangeValueForKey:@"isExecuting"]; finished_ = YES; [self didChangeValueForKey:@"isExecuting"]; } while(!finished_) { [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]; } } { finished_ = YES; } [self didChangeValueForKey:@"isFinished"]; }
This works well now :)
------
My new business with my wife, wholesale meddle-to-high end men's seamless underwear in the Netherlands: https://ecosharelife.com
|
Senry currently is an iOS Developer living in Amsterdam, the Netherlands. If you got any questions plz feel free to contact me with mail or gtalk: senryxie@gmail.com Or if you got an QQ, mine is 63793476.
2012年8月9日星期四
Asynchronous NSURLConnection with NSOperation
When I work on NSURLConnection with NSOperation today, I alloc a NSURLConnection like this
订阅:
博文评论 (Atom)
没有评论:
发表评论