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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:03:32+00:00 2026-06-14T20:03:32+00:00

Right now I am dispatching a block of code inside a method to go

  • 0

Right now I am dispatching a block of code inside a method to go download stuff for me using following format:

dispatch_queue_t downloader("downloader", NULL);
dispatch_async (downloader, ^{

//do stuff

});

what I am trying to do now is have that block return a UIImage for me, which I can then use as the return for the method:

-(UIImage *) myMethod:

dispatch_queue_t downloader("downloader", NULL);
dispatch_async (downloader, ^{

//do stuff to get UIImage

     dispatch_async (dispatch_get_main_queue, ^{

     return UIImage;  //this is the image that image I want myMethod to return

     });    
});

how ever I am getting passing parameter to incompatible type errors. I realize that is because I am not declaring that the block has a return value.

How can I declare that the block returns a UIImage right inside dispatch_async? Is this even possible or is would the method already be done by the time the block finishes execution?

  • 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-14T20:03:33+00:00Added an answer on June 14, 2026 at 8:03 pm

    Well, using the return would require your method to be synchronous, so there’s no solution that way. You will need to use a block as part of the function, like this:

    - (void)myMethodOnFinish:(void(^)(UIImage *))finishBlock {
    
        dispatch_queue_t downloader("downloader", NULL);
        dispatch_async (downloader, ^{
    
            //do stuff to get UIImage
            UIImage *result = ...;
    
             dispatch_async (dispatch_get_main_queue, ^{
             //this is the image that image I want myMethod to return
                 finishBlock(result);
            });    
        });
    }
    

    and call like this:

    [self myMethodOnFinish:^(UIImage *image) {
    
        self.imageView.image = image; // or whatever you need to do            
    
    }];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now I'm using the following command to compile a coffeescript file each time
Right now I am listing all of a users microposts using the code below.
Right now, I've just some code which fetches the picture from the URL directly.
Right now I am using sqlite within a ios application, and I want to
Right now I have the following query: User.find(:all, :conditions => [guest = ? AND
Right now, I have basic code for moving the textfield above the keyboard when
Right now I've programmed a method for use in a swing program that is
Right now I am using learning to program for the iphone and I am
Right now I have: Time.strftime(%I:%M%p) which gives me the hr:min AM/PM format which I
Right now I am writing some Python code to deal with massive twitter files.

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.