-1

Im trying to grab the artistId from this JSON

{
  "wrapperType": "track",
  "kind": "podcast",
  "artistId": 125443881,
  "collectionId": 523121474,
  "trackId": 523121474,

when creating my podcast object. but when i try to display this variable as a string, it returns null. how do i fix this?

This is where I am trying to access the artistID

  NSNumber *podcastID = episode.podcast.artistID;
NSString *episodeNumber = [episode.title stringByReplacingOccurrencesOfString:@" " withString:@"-"];
NSString *deeplinkURL = [NSString stringWithFormat: @"podcast://%@/%@",podcastID, episodeNumber];

The string makes "podcastID" (null) in all instances.

And here is the iTunes response, where I assign the artist ID

     response.artistId = [[dictionary objectForKey:@"artistId"] integerValue];
  • Set a breakpoint in your mapping code to verify if the artistId is being correctly assigned. – Rafał Sroka Nov 13 '15 at 23:25
  • You left out all of the important code. Show how and where you parse the JSON and assign the `artistId` property. And show how you try to display it as a string. – rmaddy Nov 13 '15 at 23:41
  • You share some JSON, but don't show us how you parsed it, nor how either `episode` or its `podcast` or its `artistID` is populated. Without that, no one can tell you why your `podcastID` variable is `nil`. – Rob Nov 14 '15 at 07:42

1 Answers1

0

Try using NSNumber instead:

self.artistId = [(NSNumber *)[response valueForKey:@"artistId"] integerValue];
dpigera
  • 3,339
  • 5
  • 39
  • 60