(NSURLDownload)The control never reaches downloadDidFinish:

  • Hi

    I am downloading a file from the server.
    Its a zip file and I need to uarchive it.
    I have the code in place (copied below) and I
    unarchive the file in downloadDidFinish:
    But the control doesn't seem to reach
    downloadDidFinish:
    There is no syntax error.

    What should I do?

    Thank you
    DG

    code:
    -----------------------------------------------
    NSURLRequest *request;
          request= [NSURLRequest requestWithURL:[NSURL
    URLWithString:breakPath]

    cachePolicy:NSURLRequestReloadIgnoringCacheData
                                timeoutInterval:60.0];
    NSURLDownload *download = [[NSURLDownload alloc]
    initWithRequest:request

          delegate:self];
          [download autorelease];

          // assigning the complete path to the
    destination
          NSString *destination =
            [garage_
    stringByAppendingString:kNewBreakPath];

          if (download) {
            // This will go and download
            [download setDestination:destination
    allowOverwrite:YES];
          }

    ------------------------------

    - (void)downloadDidFinish:(NSURLDownload *)download {

      NSString *breakPath = [framePath_ stringValue];
      breakPath = [breakPath
    stringByTrimmingCharactersInSet:
                      [NSCharacterSet
    whitespaceAndNewlineCharacterSet]];

      NSString *presentDestination =
        [garage_ stringByAppendingString:kNewBreakPath];

      NSString *finalDestination =
        [[garage_ stringByAppendingString:kNewBreakPath]
          stringByAppendingPathExtension:[breakPath
    pathExtension]];

      NSFileManager *fileManager = [NSFileManager
    defaultManager];
      [fileManager movePath:presentDestination
    toPath:finalDestination handler:nil];

      // this will unarchive the zipped/dmg file
    downloaded.
      [self unarchiveDownloadedFile:finalDestination];

    }

          Why delete messages? Unlimited storage is just a click away. Go to http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html
  • On Sep 27, 2007, at 5:18 PM, deepak gopal wrote:

    > I am downloading a file from the server.
    > Its a zip file and I need to uarchive it.
    > I have the code in place (copied below) and I
    > unarchive the file in downloadDidFinish:
    > But the control doesn't seem to reach
    > downloadDidFinish:
    > There is no syntax error.
    >
    > What should I do?

    Are you sure the download didn't fail? -downloadDidFinish: doesn't
    get called if the download failed for some reason.

    Nick Zitzmann
    <http://www.chronosnet.com/>
  • On Sep 27, 2007, at 7:18 PM, deepak gopal wrote:

    > Hi
    >
    > I am downloading a file from the server.
    > Its a zip file and I need to uarchive it.
    > I have the code in place (copied below) and I
    > unarchive the file in downloadDidFinish:
    > But the control doesn't seem to reach
    > downloadDidFinish:
    > There is no syntax error.
    >

    I'm just guessing here.. but

    > cachePolicy:NSURLRequestReloadIgnoringCacheData
    > timeoutInterval:60.0];
    > NSURLDownload *download = [[NSURLDownload alloc]
    > initWithRequest:request
    >
    > delegate:self];
    > [download autorelease];
    >

    you're autoreleasing download. that means that it can disappear as
    soon as the method finishes, if not at the start of the next runloop.
    and NSURLDownload requires a runloop running to work.

    So, my guess is that the object is being released and things are never
    finishing as a result.
  • Hi

    My app gets into downloadDidFinish only if I run it in
    Debug mode.
    Even then it seems to be waiting for something. It
    waits for about a second or two to print the logs in
    downloadDidFinish when in Debug.

    But if I run the app in release, it just crashes when
    downloadDidFinish is called.
    Yes I even have downlod:didFailWithError but its not
    even reaching this.
    What may be going wrong?

    Deepak
    PS: the code is the same as below

    > code:
    > -----------------------------------------------
    > NSURLRequest *request;
    > request= [NSURLRequest requestWithURL:[NSURL
    URLWithString:breakPath]
    cachePolicy:NSURLRequestReloadIgnoringCacheData
    timeoutInterval:60.0];
    >
    > NSURLDownload *download = [[NSURLDownload alloc]
    > initWithRequest:request delegate:self];
    >
    > [download autorelease];
    >
    > // assigning the complete path to the destination
    >
    > NSString *destination =  [garage_
    stringByAppendingString:kNewBreakPath];
    >
    >
    > if (download) {
    > // This will go and download
    > [download setDestination:destination
    allowOverwrite:YES];
    >
    > }
    >
    > ------------------------------
    >
    > - (void)downloadDidFinish:(NSURLDownload *)download
    > {
    > NSString *presentDestination =  [garage_
    stringByAppendingString:kNewBreakPath];
    >
    > NSString *finalDestination =
    > [[garage_ stringByAppendingString:kNewBreakPath]
    stringByAppendingPathExtension:[breakPath
    pathExtension]];
    >
    >
    > NSFileManager *fileManager = [NSFileManager
    defaultManager];
    >
    > [fileManager movePath:presentDestination
    toPath:finalDestination handler:nil];
    >
    >
    > // this will unarchive the zipped/dmg file
    downloaded.
    > [self unarchiveDownloadedFile:finalDestination];
    >
    > }

    --- Nick Zitzmann <nick...> wrote:

    >
    > On Sep 27, 2007, at 5:18 PM, deepak gopal wrote:
    >
    >> I am downloading a file from the server.
    >> Its a zip file and I need to uarchive it.
    >> I have the code in place (copied below) and I
    >> unarchive the file in downloadDidFinish:
    >> But the control doesn't seem to reach
    >> downloadDidFinish:
    >> There is no syntax error.
    >>
    >> What should I do?
    >
    > Are you sure the download didn't fail?
    > -downloadDidFinish: doesn't
    > get called if the download failed for some reason.
    >
    > Nick Zitzmann
    > <http://www.chronosnet.com/
    >

          Travelling to a new city? Search for ATMs in that city. Go to http://in.maps.yahoo.com
  • On Sep 28, 2007, at 12:25 PM, deepak gopal wrote:

    > My app gets into downloadDidFinish only if I run it in
    > Debug mode.
    > Even then it seems to be waiting for something. It
    > waits for about a second or two to print the logs in
    > downloadDidFinish when in Debug.
    >
    > But if I run the app in release, it just crashes when
    > downloadDidFinish is called.
    > Yes I even have downlod:didFailWithError but its not
    > even reaching this.
    > What may be going wrong?

    As someone else already suggested, try not releasing (or
    autoreleasing) the object until it's finished.

    Nick Zitzmann
    <http://www.chronosnet.com/>
  • This may sound rubbish, but the fact is that the code
    runs fine when I build and run it the second time, but
    the first run always fails.
    I don't understand why.
    I tried removing [download autorelease] and running
    it, but it didn't work. So I reverted back to the
    original code.

    Deepak
    --- Scott Anguish <scott...> wrote:

    >
    > On Sep 27, 2007, at 7:18 PM, deepak gopal wrote:
    >
    >> Hi
    >>
    >> I am downloading a file from the server.
    >> Its a zip file and I need to uarchive it.
    >> I have the code in place (copied below) and I
    >> unarchive the file in downloadDidFinish:
    >> But the control doesn't seem to reach
    >> downloadDidFinish:
    >> There is no syntax error.
    >>
    >
    > I'm just guessing here.. but
    >
    >
    >> cachePolicy:NSURLRequestReloadIgnoringCacheData
    >> timeoutInterval:60.0];
    >> NSURLDownload *download = [[NSURLDownload alloc]
    >> initWithRequest:request
    >>
    >> delegate:self];
    >> [download autorelease];
    >>
    >
    > you're autoreleasing download. that means that it
    > can disappear as
    > soon as the method finishes, if not at the start of
    > the next runloop.
    > and NSURLDownload requires a runloop running to
    > work.
    >
    > So, my guess is that the object is being released
    > and things are never
    > finishing as a result.
    >
    >

          Get the freedom to save as many mails as you wish. To know how, go to http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html
previous month september 2007 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Go to today