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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:35:46+00:00 2026-06-16T03:35:46+00:00

I have an application (Xcode 4.5) which downloads images from Flicker. I have a

  • 0

I have an application (Xcode 4.5) which downloads images from Flicker. I have a mapview which drops a pin for the location of each photo. Clicking the pin reveals an annotation which shows the name of the photo and a thumbnail of its image. Everything was working fine until I decided to download the thumbnail image off the main thread (my first attempt at multi threading). With the code I currently have, the annotation no longer reveals the thumbnail.

There are 4 methods I have set up to perform this task. The fourth method is not even being called. I am hoping someone can look at this code and point out obvious errors and/or a different way of attempting this:

In my mapview controller class:

//an annotation was selected
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)aView
{
self.currentAnnotationView = [[MKAnnotationView alloc]init];
self.currentAnnotationView = aView;
[self.delegate mapViewController:self 
    imageForAnnotation:self.currentAnnotationView.annotation];
}

Using delegation, the above method calls the following in my tableview controller class:

// downloads Flickr image
- (void )mapViewController:(MapViewController *)sender imageForAnnotation:    
      (id<MKAnnotation>)annotation
{      
FlickrPhotoAnnotation *fpa = (FlickrPhotoAnnotation *)annotation;

dispatch_queue_t downloadQueue = dispatch_queue_create("flickr annotation image  
       downloader", NULL);
dispatch_async(downloadQueue, ^{
    NSURL *url = [FlickrFetcher urlForPhoto:fpa.photo format:FlickrPhotoFormatSquare]; 
    NSData *data = [NSData dataWithContentsOfURL:url];
    self.thumbnailImage = [UIImage imageWithData:data];
        dispatch_async(dispatch_get_main_queue(), ^ {
            MapViewController *mvc = [[MapViewController alloc]init];
            [mvc setAnnotationImage];  
        });
    });
}

The above method calls the below message through an instance of mapview controller class:

//gets thumbnail image and sets it to the annotation view
 - (void)setAnnotationImage
 {
 UIImage *image = [self.delegate getThumbnailImage];
 [(UIImageView *)self.currentAnnotationView.leftCalloutAccessoryView setImage:image];
 }    

Finally, the above method uses delegation to call the below method in the table view controller class (which is not being called – don’t know why):

//returns the thumbnail image acquired in download
 - (UIImage *)getThumbnailImage;
 {
    return self.thumbnailImage;
 }  
  • 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-16T03:35:47+00:00Added an answer on June 16, 2026 at 3:35 am

    The method doesn’t get called because you are not setting the delegate of your second mapViewController:

    dispatch_async(dispatch_get_main_queue(), ^ {
                MapViewController *mvc = [[MapViewController alloc]init];
                [mvc setAnnotationImage];  
                [mvc setDelegate:self];
            });
    

    should be:

    dispatch_async(dispatch_get_main_queue(), ^ {
                MapViewController *mvc = [[MapViewController alloc]init];
                [mvc setDelegate:self];
                [mvc setAnnotationImage];  
            });
    

    …but you shouldn’t be making a new mapViewController, you should be setting the annotation image on your existing mapViewController (sender).

    dispatch_async(dispatch_get_main_queue(), ^ {
                [sender setAnnotationImage];  
            });
    

    …and in your call to setAnnotationImage, you might as well pass in the UIImage (as you have that info when you pass the message), obviating the need for the last delegate callback:

    change the setAnnotationImage method to receive the image:

    - (void)setAnnotationImage:(UIImage*)image
     {
     [self.currentAnnotationView.leftCalloutAccessoryView setImage:image];
     }  
    

    Then you can set it in one go:

    dispatch_async(dispatch_get_main_queue(), ^ {
                [sender setAnnotationImage:self.thumbnailImage];  
            });
    

    …and self.thumbnailImage might not need to be an iVar if this is the only place you need to get it…

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

Sidebar

Related Questions

I have an application (Xcode 4.5) which downloads images from Flicker. I have a
I have installed from XCode -> Preferences -> Downloads the Command Line Tools .
I have a mac os x application, which was developed in Xcode 3.1.1, now
I have an Xcode project which builds a Cocoa desktop Browser application. My Browser
I have an iPad application which has many categorized images I need to switch
I have an application (installer, actually) that was built outside of Xcode which I
I have developing an iPhone application using xcode 4 which is compatible with iOS
I have an application in XCode using the sqlite/coredata database and that has already
I have a master detail Application in xCode. In Master View Controller an Array
I have snow leopard and I'm building a cpp Application with xcode. I would

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.