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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:08:12+00:00 2026-05-28T20:08:12+00:00

I want to update a label on an iPhone form from a separate thread.

  • 0

I want to update a label on an iPhone form from a separate thread. The thread is running but the label is not updated.

here is my code

-(void)launchThread:(id)param;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;

...

-(void) launchThread:(id)param{
UILabel *control = (UILabel*)param;
NSMutableString *str;
for (int i=0; i<1000; i++) {
    str = [NSMutableString stringWithFormat:@"%d",i];
    control.text=str;
    NSLog(@"%@",str);
    sleep(1);
}}

...

- (void)viewDidLoad {
    [super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
    [NSThread detachNewThreadSelector:@selector(launchThread:) toTarget:self withObject:timeLabel];
}

I guess the label’s text is updated but not refreshed on the form. How do I refresh it?

I have tried to look for similar posts but they did not work for me. Sorry if I repeated the question.

  • 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-28T20:08:13+00:00Added an answer on May 28, 2026 at 8:08 pm

    @jackslash is correct, you can only update the interface on the main thread (UI thread). I would suggest using performSelectorOnMainThread to update your UILabel. I think the syntax is something like:

    [self.label performSelectorOnMainThread : @ selector(setText : ) withObject:str waitUntilDone:YES];
    

    Not quite certain tho. Do some googling and you should be able to find a working example with it.

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

Sidebar

Related Questions

I want to update label of Form1 from Form2 . So here's what I
I want to update/edit a devise user from my own form in my project,
I want to update a field in my html form separately from the rest.
i want to update my sqlite database but i cannot find the way to
So I have this text input in a form, and I want to update
I am running a synchronise process on the main thread because I don't want
I want to update the self.CreateStatusBar() in MainWindow from MainPanel. And update the self.textOutput
Example: I have this block, and I want to update a label on the
I have a process that runs long, and I want to update a label
Possible Duplicate: How to update GUI from another thread in C#? My Timer event

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.