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

  • Home
  • SEARCH
  • 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 3450942
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:05:52+00:00 2026-05-18T09:05:52+00:00

How to call setNeedsDisplayInRect using performSelectorOnMainThread? The problem is rect. I do not know

  • 0

How to call setNeedsDisplayInRect using performSelectorOnMainThread? The problem is rect. I do not know how to pass the rect in performSelectorOnMainThread method. This method ask NSObject, but CGRect is not NSObject, it is just structure *.

//[self setNeedsDisplayInRect:rect];
[self performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:0 waitUntilDone:YES];
}

-(void)drawRect:(CGRect)rect {

    /// drawing...

}

I need to invoke setNeedsDisplayInRect method in MainThread from not Main Thread.
Does anyone know how to do it?????????? Thanks in advance..

Really Thanks.

  • 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-18T09:05:52+00:00Added an answer on May 18, 2026 at 9:05 am

    If you’re on iOS 4.0 or later, you can use the following

    dispatch_async(dispatch_get_main_queue(), ^{
        [self setNeedsDisplayInRect:theRect];
    });
    

    On iOS 3.2 and earlier, you can set up an NSInvocation and run that on the main thread:

    NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[self methodSignatureForSelector:@selector(setNeedsDisplayInRect:)]];
    [invocation setTarget:self];
    [invocation setSelector:@selector(setNeedsDisplayInRect:)];
    // assuming theRect is my rect
    [invocation setArgument:&theRect atIndex:2];
    [invocation retainArguments]; // retains the target while it's waiting on the main thread
    [invocation performSelectorOnMainThread:@selector(invoke) withObject:nil waitUntilDone:YES];
    

    You may want to set waitUntilDone to NO unless you absolutely need to wait for this call to finish before proceeding.

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

Sidebar

Related Questions

We call a .live() method like this: $('.link').live('click', loadContent); But what about if I'm
When I call setNeedsDisplayInRect on a UIView , and the drawRect: method fires, am
Call this from a QWidget: Parser->xmlParser(_layout, xmlPath, comingFrom, mapCount); , but get two No
Call me a 'n00b', but I am new to creating Script Controls. I want
How do I call a function, using a string with the function's name? For
Call me lame, but I'm tired of my subconscious C-x C-s nervous twitch. I
Call me crazy, but I'm the type of guy that likes constructors with parameters
Problem: Call to send() , returns Winsock Error 10038 against socket handle Illustration: acceptedSocket
I call a template like this: <xsl:call-template name=trip_form> <xsl:with-param name=header select='Spara din resa' />
This call // this._cfg is an NHibernate Configuration instance this._sessionFactory = this._cfg.BuildSessionFactory(); Gives me

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.