Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 4    Views: 32

NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
02/23/15 07:40 PM (9 years ago)

Images saved via BT_fileManager saveImageToFile NOT found after an App refresh

Everything works fine until the App is refreshed. Then the code below in (b) does not find the image? Why would images no longer be found? ============================== // (a) This saves image no problem: [BT_fileManager saveImageToFile:theImageView.image fileName:imageName]; // (b) Check for image and load if found: if([BT_fileManager doesLocalFileExist:@"mySavedImage.png"]){ // do stuff with the image UIImage *screenImage = [BT_fileManager getImageFromFile: @"mySavedImage.png"]; }
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/23/15 08:29 PM (9 years ago)
I can't speak with authority, but I have noticed a few 'behavioral' things to keep in mind while working with files, not images (which, on the whole is the same thing). While the app is running, keep in mind you can only save 'to the cache', not the bundle. A LOT of the BT routines (if you look at them) check the 'bundle' for the file, despite them being in the cache. It was something I wanted to discuss with David, but figured I'd wait until he wasn't so busy, perhaps in 2017... ;) So, you 'can' save files to the app cache, but unless the routine 'looks in the cache', it'll never know it's there. And again, this may not be your problem but it's my problem, and possibly related. Cheers! -- Smug Or you could change the core methods to look for a cached version of the filename... this might be a little tricky, only because the BT methods typically save the file with a unique name concatenated with the app Guid attached to it. But it may not matter; I haven't looked 'that' far into it yet... other things to do first.
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
02/24/15 08:38 AM (9 years ago)
When the app goes through a refresh, it deletes almost all cached files. This isn't a iOS feature, but rather something baked into the Buzztouch core. However, there is an exception - anything that starts with "persist". So, if you name your file "persist_myImage.png" when you save it to cache, it won't get deleted when the app is refreshed.
 
NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
like
02/24/15 08:09 PM (9 years ago)
Smug - Thanks for the confirmation. It was really bugging me as I am constantly refreshing during testing. Chris - Wow I wish I had checked messages earlier today- that is a great tip! Will try that in any further parts of this App and beyond that require saving/loading images to cache. That is because I just finished adding new methods for saveImageToPhone, removeImage, and load using documentsDirectory to handle the images when I refresh. - At least the issue is my rear view mirrow, and can refresh away ;) Thanks guys.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/24/15 08:18 PM (9 years ago)
Chris, Thanks for reminding me. I knew that, but I forgot I knew that. I put that in my snippet code so I won't forget again (hopefully). Cheers! -- Smug
 

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.