1

我目前正在开发适用于 iOS 的广播应用程序。为了节省时间,我的朋友向我发送了他的工作代码,以获取 iTunes 专辑插图以及适当的头文件。我的问题是,在构建应用程序时,我收到错误消息,指出 JSON 与 ARC 不兼容。这个特定问题有不同的解决方法吗?

这是我现在使用的代码:

NSString *searchURL = [NSString stringWithFormat:@"https://itunes.apple.com/search?term=%@&media=music&limit=1", xxxx];


    NSData *searchData = [NSData dataWithContentsOfURL:[NSURL URLWithString:[searchURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
    BOOL bAlbumArtAdded = NO;

    NSDictionary *searchDict = [searchData objectFromJSONData];
    NSArray *searchResults = [searchDict objectForKey:@"results"];
    if (searchResults != nil)
    {
        if ([searchResults count] > 0)
        {
            NSDictionary *searchResult = [searchResults objectAtIndex:0];
            if ([searchResult objectForKey:@"artworkUrl100"] != nil)
            {
                NSString *viewURL = [NSString stringWithFormat:@"%@", [[searchResult objectForKey:@"artworkUrl100"] substringFromIndex:0]];

                NSString *albumDescription = [NSString stringWithFormat:@"%@", [[searchResult objectForKey:@"copyright"] substringFromIndex:0]];

                NSString *viewURL170 = [viewURL substringToIndex:([viewURL length] - 14)];

                NSString *viewURLNEW = [NSString stringWithFormat:@"%@170x170-75.jpg", viewURL170];
                NSLog(@"This is image url: %@",viewURLNEW);
                NSLog(@"This is image url: %@",albumDescription);
                [_coverImage setImage:[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:viewURLNEW]]]];



                bAlbumArtAdded = YES;
            }
        }
    }
    if (!bAlbumArtAdded)
    {
     //   [_coverImage setImage:[_radioLogo objectAtIndex:playerIndex]];
    }
4

0 回答 0