iphone - Created NSURL is null -
nsurl
printing null
. what's reason?
nsstring *webstr = [[nsstring alloc] initwithformat:@"%@",[webarray objectatindex:1]]; nslog(@"urlstring = %@",webstr); // printing correct url string nsurl *weburl = [[nsurl alloc] initwithstring:webstr]; nslog(@"url = %@",weburl); // printing null [weburl release]; [webstr release];
you should following.
nsstring *webstr = [[nsstring alloc] initwithformat:@"%@",[webarray objectatindex:1]]; nslog(@"urlstring = %@",webstr); // printing correct url string nsurl *weburl = [[nsurl alloc] initwithstring:[webstr stringbyaddingpercentescapesusingencoding:nsasciistringencoding]]; nslog(@"url = %@",weburl); // should print [weburl release]; [webstr release];
i have used nsasciistringencoding can use utf8 or other encoding.
Comments
Post a Comment