Using MKAbeFook for my iphone application

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

  1. reetu.raj macrumors newbie

    Joined:
    Mar 12, 2009
    #1
    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
    Code:
    [parameters setValue:@"pic" forKey:@"fields"];
    [parameters setValue:@"first_name" forKey:@"fields"];
    
    then I am displaying the paramaters
    Code:
    [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:
    Code:
    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

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

    Code:
    [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:

    Code:
    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];
    
     

Share This Page