Here Below is my code
NSString *string = [NSString stringWithFormat:@" http://abc.com /Demo/View.php?drinkId=%@&name=%@&comment=%@&date=%@&rating=%@& ReqestType=SubmitComment",DrinkId,Name,Comment,Date,Rating];
NSURL *url = [[NSURL alloc] initWithString:string];
Here in string there is value but url returns nil. Can Anyone tell why this happened.
Thanks ....
"This won't work, so here's what I did instead"
NSString *string = [NSString stringWithFormat:@"http://abc.com/Demo/View.php?drinkId=%@&name=%@&comment=%@&date=%@&rating=%@&ReqestType=SubmitComment",DrinkId,Name,Comment,Date,Rating];
NSURL *url = [[NSURL alloc] initWithString:string];
NSURL will return nil for URLs that contain illegal chars, like spaces.
Before using your string with [NSURL URLWithString:]
make sure to escape all the disallowed chars by using [NSString stringByAddingPercentEscapesUsingEncoding:]
.
Here is the class reference for NSString.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With