Using MKAbeFook for my iphone application

Discussion in 'iOS Programming' started by reetu.raj, Mar 12, 2009.

  1. reetu.raj macrumors newbie

    Mar 12, 2009
    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 !
  2. buckyballs macrumors regular

    Dec 22, 2006
    I can see the issue. Your problem lies here:

    [user_profile_pic setImage:[[UIImage [B]imageNamed[/B]:[[[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 = @"";
    NSURL *url = [NSURL URLWithString:path];
    NSData *data = [NSData dataWithContentsOfURL:url];
    UIImage *img = [[UIImage alloc] initWithData:data cache:NO];

Share This Page