having trouble getting NSSTRING to convert to NSURL, item.image, holds the url for an image that im getting through xml
NSString *urlString = [NSString stringWithFormat:@"%@", item.image]; NSURL *url = [NSURL URLWithString:urlString]; NSLog(@"string> %@ ", urlString); NSLog(@"url> %@ ", url); 2011-06-23 11:18:49.610 Test[10126:207] string> http://www.harlemfur.com/images/Dog_Olive.jpg 2011-06-23 11:18:49.611 Test[10126:207] url> (null)
also if i try :
NSString *urlString = [NSString stringWithFormat:@"%@", item.image]; NSURL *url = [NSURL fileURLWithPath :urlString]; 2011-06-23 11:22:08.063 Test[10199:207] string> http://www.harlemfur.com/images/Dog_Olive.jpg 2011-06-23 11:22:08.064 Test[10199:207] url> %0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20http://www.harlemfur.com/images/Dog_Olive.jpg%0A%20%20%20%20%20%20%20%20%20%20%20%20 -- /
If you get an error on your iPhone, iPad, or iPod touch that says Cannot play title. Please try again later. ( NSURL:1200;) It usually means a network connectivity issue is preventing the device from reaching the Netflix service. Follow the steps below to fix the problem.
An NSURL object is composed of two parts—a potentially nil base URL and a string that is resolved relative to the base URL. An NSURL object is considered absolute if its string part is fully resolved without a base; all other URLs are considered relative.
When making URL
from NSString
, don't forget to encode it first, so try this:
NSString *urlString = [NSString stringWithFormat:@"%@", item.image]; NSURL *url = [NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
For IOS ≥ 9.0 use
NSURL *url = [NSURL URLWithString:[urlString stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]];
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