Strange problem with NSURL with Xocode6.1

advertisements

I have a strange issue with Xcode6.1

_mainURl is my ' ServerLink '

service is ' GetUserById '

NSString* str = [NSString stringWithFormat:@"%@%@",_mainURl,service];
NSURL *url = [NSURL URLWithString:str];

When I append two strings and Create a url with NSURL, url getting 'null'

But, When I directly given the server link followed by serviceName I can generate URL.

NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"ServerLink/GetUserById"]];


Based on what you have written, the string you format would be "ServerLinkGetUserById". That is different to the string you enter manually of @"ServerLink/GetUserById".

Try updating your format to be:

NSString* str = [NSString stringWithFormat:@"%@/%@",_mainURl,service];