Vix Hunk Vix Hunk - 1 year ago 89
Objective-C Question

facebook profile picture url not passing in NSURL

i am trying to pass profile pic url which is in the formate

but when i pass it like

NSString *fbpicurl = @"";

NSString *post =[[NSString alloc] initWithFormat:@"profilepic=%@",fbpicurl];
NSURL *url=[NSURL URLWithString:@""];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];

when i pass it this way url do not pass completely it just cut of where if founds
right after
please help me how can i pass complete url string.

Answer Source

First encode your url string.

 + (NSString *) addPercentEscapesAndReplaceAmpersand: (NSString *) yourUrlString
        NSString *encodedString = [yourUrlString stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]; 
        return [encodedString stringByReplacingOccurrencesOfString: @"&" withString: @"%20"];

Then used string for url by using NSURL URLWithString

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download