0

I'm using this library (http://code.google.com/p/skpsmtpmessage/) to send email in my iPhone app

how could I implement an UIProgressView during the sending?

thanks for any help!

Gianluca
  • 2,379
  • 3
  • 25
  • 41

1 Answers1

0
  1. 1.Create your UIProgressView in your .h along with a BOOL and NSTimer and a function call it updateProgress

    2.Synthesize in your .m file

    3.In your "viewDidLoad" set initial value of BOOL to NO , and create a timer

Your .h file should include

UIProgressView * progressView;
BOOL emailSent;
NSTimer * timer;

-(void)updateProgress;
@property(nonatomic, retain)UIProgressView * progressView;
@property(nonatomic, assign)BOOL emailSent;
@property(nonatomic, retain)NSTimer * timer;

Your .m file should include

@synthesize progressView, emailSent,timer;

//viewdidload
//set initial value to no
emailSent = NO;

//since we cant interact with UIElements on anything but the Main thread we use a timer
//because you are probably sending the email in a seperate thread
timer= [NSTimer scheduledTimerWithTimeInterval:.1 target:self selector:@selector(updateProgress) userInfo:nil repeats:YES];

//create this function
-(void)updateProgress{


    //wait for email to be done
    if (emailSent == NO) {

// you'll have to tweak this area to get the correct data "progress"    
float fullValue = .0032;
int progressInt = (app.parsedCount * z);

//progressInt is the representation of how much data has been completed.
        progressView.progress = progressInt;
    }
    else {

    //email is done 
    emailSent = YES;

        //kill the timer so it doesnt continue to run
    [timer invalidate];
    //email sent so you can remove your progress view
         [self.view removeSubView:progressView];
    }
}

Happy Coding!

Louie
  • 5,920
  • 5
  • 31
  • 45
  • 1
    ok.. but my problem is where you are saying "you'll have to tweak this area to get the correct data "progress"" thank you very much indeed ;) – Gianluca Jun 08 '11 at 13:29
  • @Louie: What Janky mentioned would be also very interesting for me! I mean i know, approximately the size of the mail, but not really how much is currently being sent (when sending an email, through the class)! I really don't want to edit the SKPSMTPMessage class to get a the current progress status, but i guess, its the only choice, right? That with the timer is actually a good point, thy by the way! – NicTesla Apr 06 '12 at 08:26