I am working on an IOS app in Xcode 6 using swift. I am new to the language and honestly I am pulling out what little hair I have.
I am about to see the following JSON results from my API call to LastFM when usingb NSLog("%@", allResults)
artist = {
bio = {
content = "\n Cher (born Cherilyn Sarkisian; May 20, 1946) is an Oscar - and Grammy- winning American singer and actress. A major figure for over five decades in the world of popular culture, she is often referred to as the Goddess of Pop for having first brought the sense of female autonomy and self-actualization into the entertainment industry. She is known for her distinctive contralto and for having worked extensively across media, as well as for continuously reinventing both her music and image, the latter of which has been known to induce controversy. \n\n <a href=\"http://www.last.fm/music/Cher\">Read more about Cher on Last.fm</a>.\n \n \nUser-contributed text is available under the Creative Commons By-SA License and may also be available under the GNU FDL.\n ";
formationlist = {
formation = {
yearfrom = 1965;
yearto = "";
};
};
links = {
link = {
"#text" = "";
href = "http://www.last.fm/music/Cher/+wiki";
rel = original;
};
};
published = "Thu, 6 Mar 2014 11:40:46 +0000";
summary = "\n Cher (born Cherilyn Sarkisian; May 20, 1946) is an Oscar - and Grammy- winning American singer and actress. A major figure for over five decades in the world of popular culture, she is often referred to as the Goddess of Pop for having first brought the sense of female autonomy and self-actualization into the entertainment industry. She is known for her distinctive contralto and for having worked extensively across media, as well as for continuously reinventing both her music and image, the latter of which has been known to induce controversy. \n\n <a href=\"http://www.last.fm/music/Cher\">Read more about Cher on Last.fm</a>.\n \n ";
yearformed = 1965;
};
image = (
{
"#text" = "http://userserve-ak.last.fm/serve/34/63186903.png";
size = small;
},
{
"#text" = "http://userserve-ak.last.fm/serve/64/63186903.png";
size = medium;
},
{
"#text" = "http://userserve-ak.last.fm/serve/126/63186903.png";
size = large;
},
{
"#text" = "http://userserve-ak.last.fm/serve/252/63186903.png";
size = extralarge;
},
{
"#text" = "http://userserve-ak.last.fm/serve/500/63186903/Cher.png";
size = mega;
}
);
mbid = "bfcc6d75-a6a5-4bc6-8282-47aec8531818";
name = Cher;
ontour = 1;
similar = {
artist = (
{
image = (
{
"#text" = "http://userserve-ak.last.fm/serve/34/98934631.png";
size = small;
},
{
"#text" = "http://userserve-ak.last.fm/serve/64/98934631.png";
size = medium;
},
{
"#text" = "http://userserve-ak.last.fm/serve/126/98934631.png";
size = large;
},
{
"#text" = "http://userserve-ak.last.fm/serve/252/98934631.png";
size = extralarge;
},
{
"#text" = "http://userserve-ak.last.fm/serve/_/98934631/Madonna+M.png";
size = mega;
}
);
name = Madonna;
url = "http://www.last.fm/music/Madonna";
},
{
image = (
{
"#text" = "http://userserve-ak.last.fm/serve/34/32340147.png";
size = small;
},
{
"#text" = "http://userserve-ak.last.fm/serve/64/32340147.png";
size = medium;
},
{
"#text" = "http://userserve-ak.last.fm/serve/126/32340147.png";
size = large;
},
{
"#text" = "http://userserve-ak.last.fm/serve/252/32340147.png";
size = extralarge;
},
{
"#text" = "http://userserve-ak.last.fm/serve/500/32340147/Sonny++Cher+sonnycherbw2.png";
size = mega;
}
);
name = "Sonny & Cher";
url = "http://www.last.fm/music/Sonny+&+Cher";
},
{
image = (
{
"#text" = "http://userserve-ak.last.fm/serve/34/98367071.png";
size = small;
},
{
"#text" = "http://userserve-ak.last.fm/serve/64/98367071.png";
size = medium;
},
{
"#text" = "http://userserve-ak.last.fm/serve/126/98367071.png";
size = large;
},
{
"#text" = "http://userserve-ak.last.fm/serve/252/98367071.png";
size = extralarge;
},
{
"#text" = "http://userserve-ak.last.fm/serve/500/98367071/Kylie+Minogue+VOGUE+AU+PNG+HQ.png";
size = mega;
}
);
name = "Kylie Minogue";
url = "http://www.last.fm/music/Kylie+Minogue";
},
{
image = (
{
"#text" = "http://userserve-ak.last.fm/serve/34/96074665.png";
size = small;
},
{
"#text" = "http://userserve-ak.last.fm/serve/64/96074665.png";
size = medium;
},
{
"#text" = "http://userserve-ak.last.fm/serve/126/96074665.png";
size = large;
},
{
"#text" = "http://userserve-ak.last.fm/serve/252/96074665.png";
size = extralarge;
},
{
"#text" = "http://userserve-ak.last.fm/serve/_/96074665/Cline+Dion.png";
size = mega;
}
);
name = "C\U00e9line Dion";
url = "http://www.last.fm/music/C%C3%A9line+Dion";
},
{
image = (
{
"#text" = "http://userserve-ak.last.fm/serve/34/97259211.png";
size = small;
},
{
"#text" = "http://userserve-ak.last.fm/serve/64/97259211.png";
size = medium;
},
{
"#text" = "http://userserve-ak.last.fm/serve/126/97259211.png";
size = large;
},
{
"#text" = "http://userserve-ak.last.fm/serve/252/97259211.png";
size = extralarge;
},
{
"#text" = "http://userserve-ak.last.fm/serve/500/97259211/RuPaul+PNG.png";
size = mega;
}
);
name = RuPaul;
url = "http://www.last.fm/music/RuPaul";
}
);
};
stats = {
listeners = 940507;
playcount = 11967702;
};
streamable = 0;
tags = {
tag = (
{
name = pop;
url = "http://www.last.fm/tag/pop";
},
{
name = "female vocalists";
url = "http://www.last.fm/tag/female%20vocalists";
},
{
name = 80s;
url = "http://www.last.fm/tag/80s";
},
{
name = dance;
url = "http://www.last.fm/tag/dance";
},
{
name = rock;
url = "http://www.last.fm/tag/rock";
}
);
};
url = "http://www.last.fm/music/Cher";
};
I have a tried the following:
func didRecieveAPIRequest(results, NSDictionary) {
let results: NSArray = results["artist'] as NSArray
I get an EXC_BREAKPOINT thrown and a crash. So tried the dictionary route and I can see the data. In fact I can get the name and bio, but I am not able get to a specific image URL. I think it has something to do with it being nested, but at the point I am at a loss because it works with calls to the Itunes API. Its probably a rookie mistake, but and help would be greatly appreciated.
Let me know if more information is needed, and please only constructive responses.
Thanks in advance.