image
image

Go Back   macosx.com > Design, Media, Programming & Scripting > Software Programming & Web Scripting

Reply
 
Thread Tools
  #1  
Old August 26th, 2002, 10:37 AM
Registered User
 
Join Date: Apr 2002
Location: Australia, Wollongong
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Syphor is on a distinguished road
Downloading Progress

Hi I'd like to make a very simple downloading program. Here is what I have and I want my progress bar to indicate where how much of the file the program has downloaded.

Anway here is my code:

Code:
/* Controller.h */

#import <Cocoa/Cocoa.h>

@interface Controller : NSObject
{
    IBOutlet id downloadProgress;
    
    NSURL *myURL;
    NSData *urlContents;
}
- (IBAction)download:(id)sender;

- (void)Bam;
@end
Code:
/* Controller.m */

#import "Controller.h"

@implementation Controller

- (IBAction)download:(id)sender
{
    myURL = [NSURL URLWithString:@"http://www.apple.com/"];
    urlContents = [myURL resourceDataUsingCache:YES];
    
    [downloadProgress setUsesThreadedAnimation:YES];
    
    [NSThread detachNewThreadSelector: @selector(Bam) toTarget: self withObject:downloadProgress];

}

- (void)Bam
{
    NSAutoreleasePool *apool=[[NSAutoreleasePool alloc] init];
    
    NS_DURING
    
    [urlContents writeToFile:[@"~/Documents/applewebsite.html" stringByExpandingTildeInPath] atomically:YES];
    [downloadProgress displayIfNeeded];
    
    NS_HANDLER
         NS_ENDHANDLER
    
    [apool release];
}
@end
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
progress bar faulty in 7B53 spitty27 Mac OS X System & Mac Software 1 September 9th, 2003 05:05 AM
Any cp-like tools with a progress indicator? rharder Unix & X11 0 June 19th, 2003 01:40 PM
icon sets for downloading... ekramer Mac OS X System & Mac Software 1 February 24th, 2003 02:18 PM
Chimera downloading - same folder everytime? ksignorini Mac OS X System & Mac Software 2 October 5th, 2002 12:18 PM
Email app problem, it keeps downloading email forever & cannot quit AvalonTokio Mac OS X System & Mac Software 4 July 3rd, 2001 11:56 PM


All times are GMT -5. The time now is 01:53 PM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.