0

I'm using NSUrlConnection and NSOutputStream to write the file. But when the file doesn't exist or there is an error while downloading I want to be able to remove the incomplete downloaded file.

Is there a operation for this? Because otherwise I get a file with 0 bytes content...

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
user1066006
  • 135
  • 3
  • 14

1 Answers1

0

Handling Stream Errors like this:

- (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode {

NSLog(@"stream:handleEvent: is invoked...");
switch(eventCode) {

    case NSStreamEventErrorOccurred:

    {
       //give alert about error
       // remove current incomplete download data here
       break;
    }

    // continued ....

   }

 }
Paresh Navadiya
  • 38,095
  • 11
  • 81
  • 132