0
- (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.

KingofBliss
  • 15,055
  • 6
  • 50
  • 72

2 Answers2

0

Did you run the current run loop by following way ?

 do {

    [[NSRunLoop currentRunLoop] runUntilDate:[NSDate date]];
  } while (done == TRUE);
AechoLiu
  • 17,522
  • 9
  • 100
  • 118
0

You seem to have omitted the streams' initialization, e.g.

NSInputStream *inputStream = [NSInputStream inputStreamWithURL: myURL];
NSOutputStream *outputStream = [NSOutputStream outputStreamToMemory];
Costique
  • 23,712
  • 4
  • 76
  • 79