Discussion Forums  >  Uncategorized

Replies: 14    Views: 395

mutzy
Aspiring developer
Profile
Posts: 841
Reg: Nov 03, 2010
Medford, MA
9,860
05/16/11 07:02 AM (14 years ago)

problems with cached documents

I have a few pdf's in my app that are kept online. I set the advanced properties to allow caching. However if I load the file in the app, then exit the app and turn on airplane mode, and go back into my app to view the pdf file it's not available. I get a message saying there was a problem downloading some data.... Shouldn't this work if the pdf file was cached?
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
05/17/11 03:30 AM (14 years ago)
Seems like it should. Do this: Run the app in the simulator with an internet connection. Load the .PDF screen. Next, look in the simulators documents directory to see if the app downloaded and saved the .PDF. My sims documents directory is here: /Users/davidbook/Library/Application Support/iPhone Simulator/4.2/Applications/UNIQUE APP ID HERE If it's not saved, check the console to see if an error is reported.
 
tonycelestino
Aspiring developer
Profile
Posts: 213
Reg: Jun 24, 2011
Maceio
4,080
like
07/16/11 06:06 PM (14 years ago)
Hi David, I have a similar issue. I have about 15 pdf files in my app, they are all hosted in dropbox but it seems the iPhone Simulator is not caching them at all. Here is what the console shows: 2011-07-16 21:36:56.130 appID[47691:207] BT_screen_webView: Downloading URL, not caching, could not determine localFileName 2011-07-16 21:36:56.141 appID[47691:207] BT_screen_webView: shouldStartLoadWithRequest: URL: http://my.dropbox.url/u/123456/public-folder/catalogos/myverycoolpdf.pdf 2011-07-16 21:36:56.141 appID[47691:207] BT_screen_webView: shouldStartLoadWithRequest: SCHEME: http The images seems to be caching alright but none of the pdfs are caching. I have set the Force Refresh option on the Document Behavior settings to No, allow caching. I believe it has something to do with the could not determine localFileName. Do you know what's going on?
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
07/16/11 07:05 PM (14 years ago)
Yup...could not determine localFileName is for sure the issue. The idea is that the device needs to 'create' a local file name to save the PDF. In your URL example, it should be trying to save the one listed as 'myverycoolpdf.pdf' If you provide a local file name in the control panel, and no URL, it won't work. That approach is for files you include in the project before you compile it. When you do provide a URL and no local file name in the control panel the code tries to figure out the file name. It does this by looking at the URL and getting the 'end' of it. This is probably not happening? Maybe do this: In the BT_Screens folder find and open BT_screen_webView.m and scroll down to about line 66 or so. You'll see where the logic is here to determine which file name to use. On line 71 you'll see how it gets the file name from the URL. Do an NSLog statement directly after this line: self.localFileName = [self.dataURL lastPathComponent]; and see what it figured out? Open the console while it's running to see the NSLog statement. Not sure what you'll come up with but that's were to start.
 
tonycelestino
Aspiring developer
Profile
Posts: 213
Reg: Jun 24, 2011
Maceio
4,080
like
07/16/11 08:39 PM (14 years ago)
Thanks for the help David. I'm sorry, but now I have even more questions! =) I did some research on NSLog in Xcode but I'm not sure I'm doing it right. Newbie question: What am I supposed to see after this NSLog statemet? I wrote NSLog(@PDF) right after the line self.localFileName = [self.dataURL lastPathComponent]; but I'm not sure what it did. (I'm lost but trying!) I was watching the console (and the BT_screen_webView.m code) and I think its somehow forcing a refresh. Could that be the problem? Or is it forcing a refresh just because it didn't download the file in the first place? But even if it was forcing a refresh, there's nothing to do with the localFileName problem, right? I don't understand why the code is unable to solve the filename for the PDF document, it does everything fine for the images. Don't they use the same method for the caching? Does the file size have any influence in this? The PDF files are about 8 to 12mb. I appreciate your help and your patience.
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
07/16/11 10:19 PM (14 years ago)
NO worries... So, NSLog statements print output to the Console. Their useful when debugging. To use it, it's NSLog(@'what to print'); The single quotes I entered here should be double in Xcode, the forum doesn't all double quotes. Crazy. The reason it's forcing the refresh is because it's not understanding how to save the file. I agree that it should be but it's not. We need to figure out why and logging the file name it pulled from the URL on line 71 is the place to start. If it's successfully getting the file name from the URL there, we'll continue down the line to see why it's not saving it.
 
tonycelestino
Aspiring developer
Profile
Posts: 213
Reg: Jun 24, 2011
Maceio
4,080
like
07/16/11 10:28 PM (14 years ago)
Ok, will try that later and I'll get back to you.
 
Trevally
Lost but trying
Profile
Posts: 12
Reg: Jul 26, 2011
location unknow...
120
like
08/31/11 07:10 AM (14 years ago)
I'm having a similar issue with my PDF's not caching on the device. did anyone workout why and what the solution to the problem is?
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
09/05/11 04:53 PM (14 years ago)
Hi Trevally: Were you able to see the output console to try to determine where the app was looking for the PDF? It should donwload it once, save it, then re-use it until it's refreshed. Open the output console with the app running to see where it's finding the PDF. a) Launch app in Xcode. Simulator or device connected, either way is fine. b) Open the console c) Navigate to the PDF screen in the app d) Look at the last dozen or so lines of the console to see if you can figure out where it's reading the PDF from.
 
Charlie
Aspiring developer
Profile
Posts: 9
Reg: Mar 03, 2011
New York
890
like
09/10/11 08:55 PM (14 years ago)
David, I am having the same issue with PDF files. The console reads.. BT_screen_webView: Downloading URL, not caching, could not determine localFileName Not sure how to use the NSlog() statement. Charlie
 
Charlie
Aspiring developer
Profile
Posts: 9
Reg: Mar 03, 2011
New York
890
like
09/18/11 10:41 PM (14 years ago)
Has anyone found a solution yet?
 
mleonard
Apple Fan
Profile
Posts: 124
Reg: Nov 01, 2011
Conway,AR
1,940
like
12/01/11 11:38 PM (14 years ago)
Having the same issue. Getting: 2011-12-02 00:37:24.603 nlc[2270:707] BT_screen_webView: showProgress 2011-12-02 00:37:24.607 nlc[2270:707] BT_viewUtilities: getProgressView 2011-12-02 00:37:24.613 nlc[2270:707] BT_screen_webView: Downloading URL, not caching, could not determine localFileName
 
Charlie
Aspiring developer
Profile
Posts: 9
Reg: Mar 03, 2011
New York
890
like
12/11/11 09:33 AM (14 years ago)
David, I have not tried it on a device yet only the simulator. the following are lines 79 - 83 of BT_screen_webView.m ------------------------------------------------------------------ 79: //if we have a dataURL, and no localFileName, figure out a name to use... 80: if(self.localFileName.length < 3 && self.dataURL.length > 3){ 81: 82: //self.localFileName = [BT_strings getFileNameFromURL:self.dataURL]; 83: //local file name is NOT COMING from the URL! -------------------------------------------------------------------- When I uncommented line 82 it seemed to fix the problem. I am very new at this and I do not know if this is right. Can someone check if I am correct?
 
giandolmen
Aspiring developer
Profile
Posts: 14
Reg: Dec 19, 2011
Padua
2,290
like
03/12/12 07:12 AM (13 years ago)
Has anyone found a solution yet? I have a similar problem... file pdf not caching. Thanks
 
Crown Solutions
Aspiring developer
Profile
Posts: 463
Reg: Nov 11, 2011
MN
13,480
like
03/23/12 07:27 AM (13 years ago)
Seeing the same thing here. Without the cached data you can not email a PDF doc either. I am using V1.5 IOS.
 

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.