Iphone 后台的NSStream未调用
Input、OutputStream委托未调用。我做错了什么。您是否按照以下方式运行当前运行循环Iphone 后台的NSStream未调用,iphone,objective-c,cocoa,ios4,ios-4.2,Iphone,Objective C,Cocoa,Ios4,Ios 4.2,Input、OutputStream委托未调用。我做错了什么。您是否按照以下方式运行当前运行循环 - (void)applicationDidEnterBackground:(UIApplication *)application { NSOutputStream *outputStream; NSInputStream *inputStream; dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIOR
- (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;
});
}
您似乎忽略了流的初始化,例如
do {
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate date]];
} while (done == TRUE);
NSInputStream *inputStream = [NSInputStream inputStreamWithURL: myURL];
NSOutputStream *outputStream = [NSOutputStream outputStreamToMemory];