Closed Greg767 closed 8 years ago
In the last year (post objective-c) I have switched from saving the response body as a file to saving the entire response using NSCoding. This in order to save all data like the header fields. When using the demo content, it's written using NSCoding. The old objective-c version uses only the saved response body. So the demo probably won't work.
If you want to test the objective-c version, then first remove everything from the PreCache folder, start the demo and browse the site. then stop the app, disconnect from the internet, start the app again and see if you an browse the the pages like you did when you were connected.
What I did was I took the 4 source files reachability and EVURLCache files and put them in a new empty project. There I activate the EVURLCache and I load a website from the internet that I can browse. Then I shut the app down, shut internet down, load the app, and its blank. Even if I change the URL to a different website and I activate the internet connexion its still blank until I delete the app and reinstall it. So it work only with internet connection and only once.
On the other hand I just finished porting your swift code back to objective-c and I was hoping it could work, but besides the activation I don't get any debug messages. The breakpoints in the callbacks are not being hit. Any ideas about this? By the way I can share the obj-c code if you want.
That would be a good idea, could you mail the project to edwin@evict.nl ? And if i make the project work, is it ok if i push it to the objective-c branch?
Great thanks! I just sent you the project.
Thanks, I have received it, I will try to take a look at it later today or at least tomorrow evening.
Great thank you very much!
Hello guys, where can I download obj-c version please? Thank you
Its in a branch named objective-c
My bad...Thank you very much :)
@Greg767 Your activate function was not good. It should have been:
+(void)activate
{
// set caching paths
NSArray *documentDirectories = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES );
NSString *documentDirectory = [documentDirectories objectAtIndex:0];
_cacheDirectory = [documentDirectory stringByAppendingPathComponent:CACHE_FOLDER];
mkdir( [_cacheDirectory UTF8String], 0700 );
_preCacheDirectory = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:PRE_CACHE_FOLDER];
// activate cache
EVURLCache *urlCache = [[EVURLCache alloc] initWithMemoryCapacity:(1<<MAX_FILE_SIZE) diskCapacity:(1<<MAX_FILE_SIZE) diskPath:_cacheDirectory] ;
[NSURLCache setSharedURLCache:urlCache];
}
But then for some reason when there is no internet connection I see the javascript instead of your site.
@evermeer Okay thanks for having looked into it. And does you site work with it?
your version set all paths to index.html so so a .js or .css will be the index.html and the next time you start the app without connection you will see that .js or .css instead of the page.
Found it! Just remove the line: localUrl = @"/"; In the function storagePathForRequest After that your site will also work offline.
Yeah excellent! Thanks a million. The xamarin binding library that I will make will also go for the community. With full credit to you of course. :) Le 21 févr. 2016 09:16, "Edwin Vermeer" notifications@github.com a écrit :
Found it! Just remove the line: localUrl = @"/"; In the function storagePathForRequest After that your site will also work offline.
— Reply to this email directly or view it on GitHub https://github.com/evermeer/EVURLCache/issues/14#issuecomment-186774660.
Great!
I will make some small changes and do some more tests and then push the code to the objective-c branch.
Happy coding! 😀
Ah, found one other thing. A trailing slash has to be appended right before the check for the index.html. It needs this line: localUrl = [@"/" stringByAppendingString:localUrl];
I have pushed the new objective-c version that includes a demo to GitHub. So you can get the complete version of EVURLCache.m from there.
Hi, Sorry to bug you with this old version, I hope there is a quick fix for it. I could load the first time your webpage, then after killing the app, either when its offline or when its online it doesn't load any webpages. Whatever URL I try to load the debug says cache found for URL, it prints the Reachability flag, the age and it stays blank. Any ideas?
Thanks a lot Greg