view raw
Vix Hunk Vix Hunk - 9 months ago 37
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.


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