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 8407775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:27:35+00:00 2026-06-09T23:27:35+00:00

Currently i am working on a chatting app, I am trying to upload the

  • 0

Currently i am working on a chatting app, I am trying to upload the image, every thing is working fine except that when image is uploading the UI freeze, so async approach came into the scene, this is what i am trying to do:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{

    [self dismissModalViewControllerAnimated:YES];
        dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0ul);
        dispatch_async(queue, ^{

        UIImage *image = [info objectForKey: UIImagePickerControllerOriginalImage]; 
        NSData *imgData = UIImageJPEGRepresentation(image, 1.0);

        //[self performSelectorOnMainThread:@selector(send:) withObject:imgData waitUntilDone:YES];

        [self send:imgData];
});

}

I am getting this error:

Tried to obtain the web lock from a thread other than the main thread
or the web thread. This may be a result of calling to UIKit from a
secondary thread. Crashing now…

  1. WebThreadLock
  2. -[UITextView setText:]
  3. -[HPTextViewInternal setText:]
  4. -[HPGrowingTextView setText:]
  5. -[chatViewController send:]
  6. __74-[chatViewController imagePickerController:didFinishPickingMediaWithInfo:]_block_invoke_0
  7. _dispatch_call_block_and_release
  8. _dispatch_worker_thread2
  9. _pthread_wqthread
  10. start_wqthread

I am using HPGrowingTextView to give a iMessage kind of expandable typing area for typing messages, but getting this problem.

I searched this error

Tried to obtain the web lock from a thread other than the main thread
or the web thread. This may be a result of calling to UIKit from a
secondary thread

peoples suggests using performSelectorOnMainThread but this approach again freeze the UI.

How to solve this conflict or is there any other approach.

Inside [self send:imageData]
...building a url and appending hFile(imageData)
[body appendData:[NSData dataWithData:hFile]];
            [body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
            // setting the body of the post to the reqeust
            [request setHTTPBody:body];

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

            NSString *imgUrl = [NSString stringWithFormat:@"http://www.www.www/uImages/thumbs/%@",returnString];
...

after uploading, thumbnail of image is returned, if I use [NSURLConnection sendAsynchronousRequest I get empty thumbnail which I am diplaying in uitableview.

  • 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-06-09T23:27:36+00:00Added an answer on June 9, 2026 at 11:27 pm

    When you want to change anything in the UI you should do it on the main thread.

    So if you want to change the text of HPGrowingTextView control you have, you can do the following:

    dispatch_async(dispatch_get_main_queue(), ^{
        growingTextView.text = @"Some text";
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

currently working on an app at work that uses a tab bar controller. The
Currently working with converting SQLException error messages into messages that are more useful for
Im currently working on a game that uses multi touch to apply zoom to
Am currently working on an application that requires users to submit posts and comments
Im currently working on an app which lists a set of objects in a
Am currently working on a site that uses a lot of cfwindow objects and
Im currently working on a project that requires the following. I need to be
Im currently working on a c# project that uses another .net library. This library
Currently working on a project in MVC-3. Trying to put the following code in
Currently working on a project I'm uploading a series of JSON files to Amazon

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.