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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:33:58+00:00 2026-06-07T08:33:58+00:00

I’m using RestKit to pull data from the Foursquare API into my iphone app,

  • 0

I’m using RestKit to pull data from the Foursquare API into my iphone app, but having trouble with the followup API call for a nested object.

Specifically:

  1. I call the Venues search API (https://developer.foursquare.com/docs/venues/search) to retrieve a list of Venues. Each Venue has a unique ID which is included in the response. I do this with the following in my ViewController:

    [objectManager loadObjectsAtResourcePath:[NSString stringWithFormat:@"%@?%@", [URL resourcePath], [URL query]] delegate:self]; 
    
  2. I then do the RestKit mapping etc and store the Venues in a data array. Everything working fine up to here.

  3. At this point I loop through the Venues in the data array, and have to make a followup API call to retrieve more details about each Venue. For each Venue, I use the unique ID and call the Venue detail API (https://developer.foursquare.com/docs/venues/venues). This is the part that stumps me. I am trying to get an NSArray of Photo objects returned from this second API call. So far I have tried variations of this:

    for (id venue in self.data){
        Venue *myvenue = (Venue *)venue;
        RKURL *URL = [RKURL URLWithBaseURL:[objectManager baseURL] resourcePath:[NSString stringWithFormat:@"/venues/%@", myvenue.venueid]  queryParameters:queryParams];
        [objectManager loadObjectsAtResourcePath:[NSString stringWithFormat:@"%@?%@", [URL resourcePath], [URL query]] delegate:self];
    }
    

    and in my mapping:

    RKObjectMapping *photosMapping = [RKObjectMapping mappingForClass:[Photo class]];
    [photosMapping mapKeyPathsToAttributes:@"url", @"imageURL", nil];  
    [venueMapping mapRelationship:@"photos" withMapping:photosMapping];
    [objectManager.mappingProvider setMapping:photosMapping forKeyPath:@"response.photos"];  // not sure if this keypath is for the second API call
    

    and my Venue class has this:

    @property (strong, nonatomic) NSArray *photos;
    

Venue.photos always returns empty. Any suggestions?

  • 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-07T08:34:01+00:00Added an answer on June 7, 2026 at 8:34 am

    Not sure if this is the ‘best’ way to do it, but I got it working in the end. Paul de Lange’s comment about not mapping the venue and the photos correctly set me off on the correct path.

    The foursquare response was not in the format that I required in my app, so I had to use RKObjectLoader’s willMapData to modify the response slightly before the rest of the mapping operation.

    Here it is in case it helps anybody in the future:

    - (void)objectLoader:(RKObjectLoader *)loader willMapData:(inout id *)mappableData {
        NSArray* origPhotosArray = [*mappableData valueForKeyPath:@"response.venue.photos.groups"];
        NSMutableArray* newPhotosArray =  [[NSMutableArray alloc] init];  
    
        // <snip> Some extra code goes here where I discarded photos I did not want....  </snip>
    
        // Create copies of objects in the format that I want
        NSMutableDictionary *myphoto = [[NSMutableDictionary alloc] initWithDictionary:Photo];
        NSString *venueID = [*mappableData valueForKeyPath:@"response.venue.id"];
        [myphoto setObject:venueID forKey:@"assignedVenueid"];
        [newPhotosArray addObject:myphoto];
    
        // Replace the new objects instead of the response objects
        [*mappableData removeObjectForKey:@"response.venue.photos.groups"];      
        [*mappableData setObject:newPhotosArray forKey:@"response.venue.photos.groups"]; 
    
    }
    

    And in my mapping:

    RKManagedObjectMapping *photosMapping = [RKManagedObjectMapping mappingForClass:[Photo class] inManagedObjectStore:objectStore];
    [photosMapping mapKeyPath:@"url" toAttribute:@"imageURL"];
    [photosMapping mapKeyPath:@"assignedVenueid" toAttribute:@"assignedVenueid"];
    [venueMapping mapRelationship:@"photos" withMapping:photosMapping];
    [objectManager.mappingProvider setMapping:photosMapping forKeyPath:@"response.venue.photos.groups"]; 
    [photosMapping hasOne:@"assignedVenue" withMapping:venueMapping];
    [photosMapping connectRelationship:@"assignedVenue" withObjectForPrimaryKeyAttribute:@"assignedVenueid"];    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I want to construct a data frame in an Rcpp function, but when I
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I'm making a simple page using Google Maps API 3. My first. One marker
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.