chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
12/04/13 03:03 PM (11 years ago)

basic image download code

since it was requested on a webcast today, here's some basic code to download an image from a url //get image -(UIImage*)getImage:(NSString *)imageLocation { UIImage *tmpImage = [[UIImage alloc]init]; //check if this is from a URL or not NSString *firstFour = [imageLocation substringToIndex:4]; [BT_debugger showIt:self message:[NSString stringWithFormat:@"First Four Characters of Image Location:%@", firstFour]]; if ([[firstFour uppercaseString] isEqualToString:@"HTTP"]) { //found url - check if cached image exists. If so, use it. If not, download and cache NSString *imageName = [BT_strings getFileNameFromURL:imageLocation]; if ([BT_fileManager doesLocalFileExist:imageName]) tmpImage = [BT_fileManager getImageFromFile:imageName]; else { tmpImage = [BT_imageTools getImageFromURL:imageLocation]; [BT_fileManager saveImageToFile:tmpImage fileName:imageName]; } } else { //not a url - attempt to get from bundle if ([BT_fileManager doesFileExistInBundle:imageLocation]) tmpImage = [UIImage imageNamed:imageLocation]; } return tmpImage; }
 
LA
Aspiring developer
Profile
Posts: 3280
Reg: Aug 16, 2012
Jerseyville, IL
42,900
like
12/04/13 03:27 PM (11 years ago)
Thank you! LA
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
12/04/13 03:40 PM (11 years ago)
Nice contribution. As always. :) Thanks Chris! Cheers! -- Smug Oh and by the way, if you didn't get a chance to download the 'test plugin' from this morning's webinar, the link is: https://dl.dropboxusercontent.com/u/115208762/SW_forTestOnly.zip
 
SheriDee
Code is Art
Profile
Posts: 1094
Reg: Sep 23, 2011
location unknow...
22,840
like
12/04/13 03:58 PM (11 years ago)
Thanks peeps! You guys rock :)
 
EdReyes
Lost but trying
Profile
Posts: 574
Reg: Oct 21, 2013
location unknow...
17,640
like
12/04/13 08:31 PM (11 years ago)
Thanks
 
0z2000tv
Aspiring developer
Profile
Posts: 315
Reg: Sep 10, 2011
Nashville
11,950
like
12/05/13 08:10 AM (11 years ago)
Thanks Chris.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.