我实现了这个来从LastFm获取一个数组。
NSError *error;
NSString *url_string = [NSString stringWithFormat: @"http://ws.audioscrobbler.com/2.0/?method=track.getInfo&api_key=47c35d956f7cd6b43ab94586f0fd3a&artist=Blondie&track=Heart+of+Glass&format=json"];
NSData *data = [NSData dataWithContentsOfURL: [NSURL URLWithString:url_string]];
NSMutableArray *json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
NSLog(@"json: %@", json);
这部分工作正常我得到了这些数据:
track = {
album = {
"@attr" = {
position = 1;
};
artist = Blondie;
image = (
{
"#text" = "https://lastfm-img2.akamaized.net/i/u/34s/ee5b3f50b00a4678c6de7b908c505fb4.png";
size = small;
},
{
"#text" = "https://lastfm-img2.akamaized.net/i/u/64s/ee5b3f50b00a4678c6de7b908c505fb4.png";
size = medium;
},
{
"#text" = "https://lastfm-img2.akamaized.net/i/u/174s/ee5b3f50b00a4678c6de7b908c505fb4.png";
size = large;
},
{
"#text" = "https://lastfm-img2.akamaized.net/i/u/300x300/ee5b3f50b00a4678c6de7b908c505fb4.png";
size = extralarge;
}
);
我的问题是如何从这个关键字#34;#text"
中获得价值"#文本" =" https://lastfm-img2.akamaized.net/i/u/174s/ee5b3f50b00a4678c6de7b908c505fb4.png&#34 ;; size = large;
类似的东西:
NSLog(@"大图:%@"," https://lastfm-img2.akamaized.net/i/u/174s/ee5b3f50b00a4678c6de7b908c505fb4.png");
我真的尝试了一切。
提前致谢。