I'm trying to get the profile picture from Facebook, but I'm getting the following error:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImage stringByStandardizingPath]:
This is my code:
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://graph.facebook.com/%@/picture?type=square", userid]];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *image = [UIImage imageWithData:data];
//convert UIImage to CCSprite
CCTexture *texture = [CCTexture textureWithFile:image];
CCSprite *sprite = [CCSprite spriteWithTexture:texture];
sprite.position = ccp(winWidth*.5, winHeight*.5);
The error occurs in the UIImage *image line.
data
for nil before passing it toUIImage
, in casedataWithContentsOfURL
has failed. \$\endgroup\$