0

After implementing the HCDownload for iOS into my app I am successfully able to display the downloading progress of a file.

The problem is that the guy who wrote it, didn't use Xcode to write the module, so even though it should, it does not really work nice when trying to integrate with a project.

These are the main issues I have with it:

If you do a [self.navigationController pushViewController:dlvc animated:YES]; or a [self presentViewController: animated: completion:]; then it shows when it is initiated. I can get out of it, by navigating back, but then when I return to it, it is blank - so I cannot see what the progress is of the download. The download however keeps going, because it appears in my documents folder. ( I use ASIHTTP framework)

Now I am working with storyboard in this project, and because this does not come with a XIB file I thought (which has kinda worked in the past) I could just have a UITableViewController and have this as its Custom Class, but it does not play ball.

Is there a XIB based Download manager FrameWork that someone can point me too, or has anyone had luck with this one?

PS I know Storyboards do not use XIB files, but that way it is easier to integrate into storyboard than no UI files at all:-)

Kind thanks for the tips.

Edit

Here is the code where I implement it:

        HCDownloadViewController *dlvc = [[HCDownloadViewController alloc] init];
    dlvc.delegate = self;

    NSString *documentDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];

    dlvc.downloadDirectory = documentDirectory;

    NSString *fileSave = [_streamingURL lastPathComponent];

    NSURL *url = [NSURL URLWithString:_streamingURL];
    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];

    [dlvc downloadURL:url userInfo:nil];

    // Add your filename to the directory to create your saved pdf location
    NSString *pdfLocation = [documentDirectory stringByAppendingPathComponent:fileSave];


    NSString *cachesDirectory = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject];
    // Add your filename to the directory to create your temp pdf location
    NSString *tempPdfLocation = [cachesDirectory stringByAppendingPathComponent:fileSave];

    if (!networkQueue) {
        networkQueue = [[ASINetworkQueue alloc] init];
    }
    failed = NO;


    [request setTemporaryFileDownloadPath:tempPdfLocation];
    [request setDownloadDestinationPath:pdfLocation];
    [request setDownloadProgressDelegate:progressBar];
    [request setShowAccurateProgress:YES];
jwknz
  • 6,598
  • 16
  • 72
  • 115
  • *"didn't use Xcode to write the module, so even though it should, it does not really work nice when trying to integrate with a project."* Why do you think so? It looked like normal code to me which can be integrated to any project. Not sure about your issue though. – iDev Dec 22 '12 at 22:15
  • @ACB OP is right, I don't use Xcode. The code doesn't look 'normal' because one uses Xcode but because one follows a reasonable coding style. The description of the problem is not very clear, however I suspect that OP is recreating and pushing a new instance of `HCDownloadViewController` again and again instead of creating just one instance. –  Dec 22 '12 at 22:18
  • @H2CO3 yeah it seems to be pushing out a new instance which is the issue – jwknz Dec 22 '12 at 22:23
  • @JeffKranenburg How are you creating it then? Seems to me that the error is not in HCDownload. Would you mind adding some code? –  Dec 22 '12 at 22:24
  • sorry I didn't mean to say non-xcode looks different, what i meant was that I thought that if you write code without xcode then it works if you know how the initial design was made - If I look at "code only" code vs IB based code than you can see the differences there. – jwknz Dec 22 '12 at 22:24
  • @JeffKranenburg my first comment was directed towards @ ACB. –  Dec 22 '12 at 22:25
  • @JeffKranenburg well, how about moving the initialization code into the `init` method of your class? –  Dec 22 '12 at 22:29
  • This code is placed inside the UIAlertViewDelegate as it is a result of a confirmation if the download needs to happen. What part would I move to the init method?? – jwknz Dec 22 '12 at 22:32
  • @JeffKranenburg `HCDownloadViewController *dlvc = [[HCDownloadViewController alloc] init];` and setting its properties. (Alloc-initting view controllers outside of an initialization method often signifies design problems...) –  Dec 22 '12 at 22:34
  • I put it there, because I do not need it before that moment - If i place it outside of the method I would not be able to access the pointer - Even if I set the pointer in the header file I still need to init is when I need it - Is that not the right way to do it?? – jwknz Dec 22 '12 at 22:36
  • @JeffKranenburg have you heard about the concept of instance variables? –  Dec 22 '12 at 22:38
  • yup - but when I have used them, I still need to initialize the object when I need it? That is what I have learned and been using on my path. Would I be better to initialize it somewhere else and have it ready before calling it here? Maybe I need to go back a bit:-) – jwknz Dec 22 '12 at 22:43
  • @JeffKranenburg alloc-init ***ONCE!!!*** (I can't shout louder) in `init` and don't touch it afterwards. –  Dec 22 '12 at 22:47
  • Yeah I get that and I am not - how can you tell I am doing it more, by the code I have shown you?? – jwknz Dec 22 '12 at 22:48
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/21581/discussion-between-h2co3-and-jeff-kranenburg) –  Dec 22 '12 at 22:48
  • @H2CO3, I didn't know that. On a quick look, I felt it looked like a normal code. Should have checked properly. – iDev Dec 22 '12 at 23:55

0 Answers0