Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6782827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:47:25+00:00 2026-05-26T16:47:25+00:00

I am trying to figure out how to update my UIProgressView while i upload

  • 0

I am trying to figure out how to update my UIProgressView while i upload a video to my server. The video is a user picked video, here is my code to upload to my server:

NSMutableArray *array = [[NSMutableArray alloc]initWithContentsOfFile:[self saveUserLogin]];

int test;
NSString *string = [array objectAtIndex:3];
test = [string intValue];
test++;
NSData *videoData = fileData;
NSString *urlString = [[NSString alloc]initWithFormat:@"http://www.site.com/members/uploadMovie.php?&username=%@", [array objectAtIndex:0]];

NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:urlString]];
[request setHTTPMethod:@"POST"];

NSString *boundary = [NSString stringWithString:@"---------------------------14737809831466499882746641449"];
NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary];
[request addValue:contentType forHTTPHeaderField:@"Content-Type"];

NSMutableData *body = [NSMutableData data];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
NSString *postName = [[NSString alloc]initWithFormat:@"Content-Disposition: form-data; name=\"userfile\"; filename=\"vid%i.mov\"\r\n", test];
[body appendData:[[NSString stringWithString:postName] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithString:@"Content-Type: application/octet-stream\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[NSData dataWithData:videoData]];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:body];


NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];

NSLog(@"%@", returnString);

NSArray *values = [[NSArray alloc] initWithObjects: [array objectAtIndex:0],[array objectAtIndex:1], [array objectAtIndex:2], [NSString stringWithFormat:@"%i", test], nil];
[values writeToFile:[self saveUserLogin] atomically:YES];
[self.delegate didFinishController:self];

My UIProgressView is named ProgressForUpload, I am guessing that i’ll have to use a new thread. This app i am making also uploads images, I am able to update the progressview for the images by doing this:

int copy = ForProgress;
    ForProgress = 100 / ForProgress;

    NSString *togetridof = [[NSString alloc]initWithFormat:@"%f", ForProgress];
    NSString *stringWithoutdot = [togetridof stringByReplacingOccurrencesOfString:@"." withString:@""];


    if(copy > 1 && copy < 11){
        progressString = [[NSString alloc]initWithFormat:@"0.%@", stringWithoutdot];
    }
    if (copy > 10) {
        progressString = [[NSString alloc]initWithFormat:@"0.0%@", stringWithoutdot];
    }
    if(ForProgress == 100){
        progressString = [[NSString alloc]initWithFormat:@"%@", stringWithoutdot];
    }

    tellprogress = [progressString floatValue];

Then while i upload images i create a new thread that will add tell progress onto the current progress, until its done.

I dont know if anything like this would apply to uploading a video though.

Thanks, Jacob

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:47:25+00:00Added an answer on May 26, 2026 at 4:47 pm

    I’d implement this using asynchronous networking, then you can update the progress bar from your

    - (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response;
    

    Apple continues to warn that networking on the main thread is bad.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

UPDATE - New code at the bottom I'm trying to figure out how to
I am trying to figure out how I can update my sql query dynamically.
I am trying to figure out how can I update the petevents table with
I'm trying to figure out a way to add a self-update feature to a
I'm trying to do a simple update, but can't figure out somthing. I have
I'm trying to figure out if it is better to store my user's data
I am trying to figure out how to update my option select menu when
I'm trying to figure out how to update an NSTextField programatically. I've figured out
I'm trying to figure out how to update the data in a binary file
I'm trying to figure out how to update the title of a cross posting.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.