简体   繁体   中英

NSInteger vs NSNumber and retrieving JSON data from itunes

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];

尝试使用 NSNumber 代替:

self.artistId = [(NSNumber *)[response valueForKey:@"artistId"] integerValue];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM