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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:17:46+00:00 2026-06-01T02:17:46+00:00

I use Grand Central Dispatch methods to do some executions of my app in

  • 0

I use Grand Central Dispatch methods to do some executions of my app in a queue. I decide the frames for buttons in a calculation on that queue. I want my app to re-draw its scren and calculate new frames after rotation. Here is some pseudo code explanation from what i do:

 CGFloat a=123, b=24;
     dispatch_async(drawingQue, ^{
        //needed loops to get the total button count-how many ones will be drawn et..
        for(int x=0;x<someCount<x++){
           for(int y=0;y<anotherCount;y++){

        //needed frame&name ect assingments

        button.frame= CGRectMake(x+y, x-y, a, b);
        [button setTitle:@"abc"];}}
        };

Here what i want is, how can i give this block a name and re-use it in the

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
} 

delegate method? For instance, if the rotation is landscape, i want to use a=234 instead of 123.. Any help please. Thanks in advance..

  • 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-01T02:17:47+00:00Added an answer on June 1, 2026 at 2:17 am

    Declare an instance variable of block type and use Block_copy to keep the block:

    @interface My {
        void (^myBlock)(void);
    }
    @end
    
    myBlock = Block_copy(^{
        ...block code...
    });
    
    // later call it
    myBlock();
    
    // don't forget to release it in dealloc
    

    It is important to copy the block before storing it outside of the scope of its literal (^{...}), because the original block is stored on stack and will die when the scope exits.

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

Sidebar

Related Questions

How do I get blocks/grand central dispatch working in Snow Leopard? It appears that
I need to send multiple tasks to Grand Central Dispatch to run. Some tasks
Use case: I've just entered insert mode, and typed some text. Now I want
One of the patterns presented at the WWDC 2010 Blocks and Grand Central Dispatch
I'm just getting started with blocks and Grand Central Dispatch. I've been told (and
I am trying to understand the proper way of using Grand Central Dispatch (GCD)
Having recently learned Grand Central Dispatch, I've found multithreaded code to be pretty intuitive(with
I have some data calculation method (let it be myMethod:), and I want to
Apple's Grand Central Dispatch reference says: ...if your application needs to operate at the
I'm a beginner with Grand Central Dispatch (GCD) and Core Data, and I need

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.