login about faq

Hello,

I have to develop an application in Xcode. I started to work with it for a short time so I'm beginner. My code is based on the CK examle codes, but I couldn't figure out how to use a progressbar during an FTP or SFTP upload.

Is there any way to get a small example code with S/FTP + progressbar support?

Thank you!

asked Jun 05 '12 at 13:36

dss's gravatar image

dss
16810


The pattern for implementing event callbacks is the same for all Chilkat classes that support it.

Your app would define and implement a class that inherits from one of the CkoProgress base classes. You provide method implementations to override the methods specified in the CkoProgress classes (see the header files). The callback object is specified via the EventCallbackObject property.

For example, to setup FTP2 event callbacks for AbortCheck, PercentDone, and BeginDownloadFile, you would create a class that inherits from CkoFtp2Progress. In this example, your application's event callback class is named MyFtpProgress. Here are snippets for the MyFtpProgress header and implementation that should make it clear:


MyFtpProgress.h:

    @interface MyFtpProgress : CkoFtp2Progress {

}

- (id)init;
- (void)dealloc;
- (void)dispose;

- (void)AbortCheck: (BOOL *)abort;
- (void)PercentDone: (NSNumber *)pctDone
              abort: (BOOL *)abort;
- (void)BeginDownloadFile: (NSString *)path 
    skip:(BOOL *)skip;

@end


MyFtpProgress.mm:

@implementation MyFtpProgress

-(id)init {
    self = [super init];
    return self;
}

-(void)dealloc {
    [super dealloc];
}

-(void)dispose {
}

- (void)AbortCheck: (BOOL *)abort
{
    *abort = NO;
    FILE *fp = fopen("eventLog.txt","a");
    fprintf(fp,"AbortCheck\n");
    fclose(fp);

}
- (void)PercentDone: (NSNumber *)pctDone
              abort: (BOOL *)abort
{
    *abort = NO;
    FILE *fp = fopen("eventLog.txt","a");
    fprintf(fp,"PercentDone: %d\n",[pctDone intValue]);
    fclose(fp);
}

- (void)BeginDownloadFile: (NSString *)path 
    skip:(BOOL *)skip
{
    *skip = NO;
    FILE *fp = fopen("eventLog.txt","a");
    fprintf(fp,"BeginDownloadFile: %s\n",[path UTF8String]);
    fclose(fp);

}

@end


The code to create an instance of MyFtpProgress and assign it as the callback object looks like this:

        ftp = [[CkoFtp2 alloc] init]; 
progressObj = [[MyFtpProgress alloc] init];

        [ftp setEventCallbackObject:progressObj];

link

answered Jun 05 '12 at 16:24

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

edited Jun 05 '12 at 16:42

Thanks, I'll try it tomorrow!

link

answered Jun 05 '12 at 16:50

dss's gravatar image

dss
16810

Hello,

I have the same result, I'm able to show the percentage with NSLog but the progress bar isn't working.

link

answered Aug 17 '12 at 02:01

dss's gravatar image

dss
16810

Ray,

The callbacks are made in real time -- that is for sure. What is likely happening is that your user interface is not refreshing with the updates until the very end. The issue here is not with Chilkat, but with your application code involving user interface refreshing/updating.

link

answered Aug 17 '12 at 08:56

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×200
×13
×3

Asked: Jun 05 '12 at 13:36

Seen: 2,916 times

Last updated: Aug 22 '12 at 05:56

powered by OSQA