简体   繁体   English

NSInteger 与 NSNumber 以及从 iTunes 中检索 JSON 数据

[英]NSInteger vs NSNumber and retrieving JSON data from itunes

Im trying to grab the artistId from this JSON我试图从这个 JSON 中获取艺术家 ID

{
  "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这是我尝试访问艺术家 ID 的地方

  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.该字符串在所有实例中都使“podcastID”(空)。

And here is the iTunes response, where I assign the artist ID这是 iTunes 响应,我在其中分配了艺术家 ID

     response.artistId = [[dictionary objectForKey:@"artistId"] integerValue];

尝试使用 NSNumber 代替:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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