PDA

View Full Version : Using MKAbeFook for my iphone application




reetu.raj
Mar 12, 2009, 05:50 AM
Hello I am using MKAbeFook to get userinfo .... I am sure someone who has used it before can help me out in sorting out my problem.

//first I am adding the request parameter

[parameters setValue:@"pic" forKey:@"fields"];
[parameters setValue:@"first_name" forKey:@"fields"];


then I am displaying the paramaters

[userInfoTextView setText:[NSString stringWithFormat:@"Hello %@", [[[response rootElement] dictionaryFromXMLElement] valueForKey:@"first_name"]]];

[user_profile_pic setImage:[[UIImage imageNamed:[[[response rootElement] dictionaryFromXMLElement] valueForKey:@"pic"]]retain]];


where I have defined in .h file following objects:

IBOutlet UITextView *userInfoTextView;
IBOutlet UIImageView *user_profile_pic;



I can see the output for first_name
but I cant see the image
Anybody having any idea what am I doing wrong in the code above ?

Thanks a lot !



buckyballs
Mar 16, 2009, 08:24 AM
I can see the issue. Your problem lies here:


[user_profile_pic setImage:[[UIImage imageNamed:[[[response rootElement] dictionaryFromXMLElement] valueForKey:@"pic"]]retain]];


This method will only retrieve an image from the app bundle (and I think, other local paths), but will definitely not retrieve an image from a URL.

I would suggest this code to create a UIImage from a URL:


id path = @"http://merrimusings.mu.nu/archives/images/groundhog2.jpg";
NSURL *url = [NSURL URLWithString:path];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[UIImage alloc] initWithData:data cache:NO];