1

I am currently working on a radio app for iOS. In an attempt to save time, my buddy sent me his working code to fetch iTunes album artwork, along with appropriate header files. My problem is that upon building the app, I get errors stating that JSON is not compatible with ARC. Is there a different workaround this particular issue?

Here is the code that I am using now:

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]];
    }
Gabriele Petronella
  • 106,943
  • 21
  • 217
  • 235
vzm
  • 2,440
  • 6
  • 28
  • 47

0 Answers0