Hi I have to send data to server via JSON and usually I do it like that:
NSMutableString * temp=[[NSMutableString alloc] initWithString:service_registra_inc];
//here I add more staff to temp
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:temp]];
[[NSURLConnection alloc] initWithRequest:request delegate:self];
but I get some error message that the url is wrong: something like url length but I have searched around and it means I have to escape my url si I have found this fonction that doesn’t work for me:
NSString *temp2=(__bridge_transfer NSString*)CFURLCreateStringByAddingPercentEscapes(NULL,((CFStringRef)temp.UTF8String),NULL,NULL,kCFStringEncodingUTF8);
and there the program just stops and it says signal EXC_BAD_ACCess.
Well I don’t really know how to transform mutable strings into CFStringRef so xcode just suggested the corrections for me but I don’t really understand what is happening. Please help…. I have read the doc but it doesn’t say how to cast NSSMutableString to CFStringRef and back or how to use the whole thing to create an NSURL object directly. Thks
Why are you using CFURL & CFStringRef functions here?
You could do what you are trying to do via NSString’s
stringByAddingPercentEscapesUsingEncoding:method. I’ve linked the documentation for you.Something like:
(don’t forget to release things if you’re not using ARC)