Playlist Generator
1.0
|
00001 // 00002 // ExtractSpotifyURI.m 00003 // Playlist2 00004 // 00005 // Created by Max Woolf on 17/12/2011. 00006 // Copyright (c) 2011 __MyCompanyName__. All rights reserved. 00007 // 00008 00009 #import "ExtractSpotifyURI.h" 00010 00011 @implementation ExtractSpotifyURI 00012 00013 -(id)initWithSpotifyJSONString:(NSString *)input 00014 { 00015 spotifyJSON = input; 00016 self = [super init]; 00017 return self; 00018 } 00019 00020 -(NSString *)getURI 00021 { 00022 parser = [[SBJsonParser alloc] init]; 00023 NSDictionary *rootDictionary = [parser objectWithString:spotifyJSON]; 00024 NSArray *tracks = [rootDictionary objectForKey:@"tracks"]; 00025 NSDictionary *trackOne = [tracks objectAtIndex:0]; 00026 NSString *URI = [trackOne objectForKey:@"href"]; 00027 NSLog(@"%@", URI); 00028 if(URI != nil) 00029 { 00030 return URI; 00031 }else{ 00032 //Failed? Give them some nyan cat! 00033 return @"spotify:track:5CXfVcqBAtCAHhnGmoxBZ9"; 00034 } 00035 00036 } 00037 @end