tags:

views:

43

answers:

2

Hi all,

This' strange because all my other NSUrls in program are working properly but this one isn't getting allocated with NSString. I'm using:

urlStr_ = [NSString stringWithFormat:@"http://192.168.10.2/justmeans/trunk/appaddgoodwork?gencode=%@&deviceid=@%@&sessionkey=%@&userid=%@&updatetext=%@&companyid=%d&service_type=%@",securitycode,deviceId,sessionKey,userId,finalTextInTxtVw,companyId,service_type];
urlStr_ = [urlStr_ stringByAddingPercentEscapesUsingEncoding:(NSStringEncoding)NSUTF8StringEncoding];

url_ = [[NSURL alloc] initWithString:urlStr_];

What are the possible reasons for NSUrl not getting allocated? Can anybody please help?

Thanx in advance.

P.S. NSString is not empty.

A: 

Useally it is because the string is not formatted correctly for encoding as an URL. Try to chop of bits of the string to find the offending part.

Claus Broch
Thanx Claus for replying.. But what do you mean by "Try to chop of bits of the string to find the offending part". I tried looking wheather the string isn't containing spaces and found out that it's not. I'm really confused.
neha
A: 

The string seems to not be correctly formatted. See the %@&deviceid=@%@&sessionkey part; should not it be %@&deviceid=%@&sessionkey?

kiamlaluno
Oh my God... Thanx for pointing out.. This' weird on my part.. Thanx for your help..
neha
Ok, it worked..
neha