NSStream on Background didn't call
- (void)applicationDidEnterBackground:(UIApplication *)application {
NSOutputStream *outputStream;
NSInputStream *inputStream;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[inputStream setDelegate:self];
[outputStream setDelegate:self];
[inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop]
forMode:NSRunLoopCommonModes];
[outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop]
forMode:NSRunLoopCommonModes];
[app endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
开发者_如何转开发});
}
Input,OutputStream delegate didn't call.What i am doing wrong.
Did you run the current run loop by following way ?
do {
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate date]];
} while (done == TRUE);
You seem to have omitted the streams' initialization, e.g.
NSInputStream *inputStream = [NSInputStream inputStreamWithURL: myURL];
NSOutputStream *outputStream = [NSOutputStream outputStreamToMemory];
精彩评论