Just do:
[str stringByReplacingOccurrencesOfString:@" " withString:@""]
Domanda
NSString* str = [inventoryDetails objectAtIndex:i];
UIImageView *imageView=[[UIImageView alloc]initWithFrame:CGRectMake(j, 10, 280, 180)];
if (![str isEqual:[NSNull null]]) {
NSData *data=[NSData dataWithContentsOfURL:[NSURL URLWithString:[[inventoryDetails objectAtIndex:i] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
UIImage *img=[[UIImage alloc]initWithData:data];
I'm getting output as
https:google.com/images/320.png
How to remove the space in url
Soluzione 2
Just do:
[str stringByReplacingOccurrencesOfString:@" " withString:@""]
Altri suggerimenti
Try this
NSString *str = @"http://...";
NSURL *url = [NSURL URLWithString:[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
You can trim your NSString if your space are on the sides.
NSString *trimMe = @" Trim this string ";
trimMe = [trimMe stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSLog(@"Trimmed String: ++%@++", trimMe);
//returnes Trimmed String: ++Trim this string+++