Offline Blog Reading (Images) capability (cache)? - ios

I am creating a UITableView where I will load and show data from my blog's feed. This data will be updated daily, on launch or dynamically.
What I want to do is provide some offline capability to this screen, as such if user isnt connected to internet, he can still see the view and its contents (mainly post list with its images).
For such I will need some hints or solutions on how to do this, probably cache ?
Basically if user is connected to net, the view will update the contents and fetch he blog post feeds from my API and update it with new content, but if user isnt connected to net, he should see the last fetched/updated content (with images) till he connects to net and updates the view.
For this probably I need to save/cache 3 things which I will need and use in the View, all of which are fetched and provided by my API:- The Post Title, Date and its cover image.
Would best way would be to add them to some dictionary, use NSCache (aint it temporary ?) or download images locally and then save them as UIImage along with NSString (title/date) in a dic/array ?
I would like to know as many different approaches possible.
After testing a bit, I found caching images can solve my offline image problem, but is cache temporary or how long can it last ? How can I store that cached image with my text data in some dictionary to load it if network isnt connected ?

You can use a ready to use, opensource caching library like SDWebImage. It provides asynchronous image downloading as well as caching, so any image that is cached will appear in place when your app is offline.

Related

How does Snapchat show text over image

I am working on an iOS app where the users can add description/text when uploading images like Snapchat.
Do they render images and add the text to image so that it becomes part of the image itself or is it shown as a UILabel over the image?
For the 2nd option the text would have to be sent separately to server.
P.S. Just having an argument with Server side programmer and I'm suggesting the 2nd option.
If we check /ph/upload in Snapchat API (last updated 23-12-2013) we can see that you can upload either a photo or a video.
Of course, this is not the latest version (although this is the last documentation I could find) but I am assumming nothing has changed in that regard.
That means the text is inserted to the photo in the mobile client app, not on the server.
In my opinion, you shouldn't base any decisions about your API architecture on Snapchat because it's unlikely you have the same use cases. In general:
Sending data separately is more flexible and makes client implementation simpler.
Rendering data on the client is better for user experience (everything is faster and the user can see the final result) and also it saves a lot of server resources (the more users you have the more this will be visible).

Where do Instagram/Facebook store images internally?

Like the title says. In an iPhone, in what directory do Instagram/Facebook (and similar applications) store the images they downloaded at runtime?
When is that directory wiped?
For non permanent images (e.g. post thumbnails but not user profile pics) I would imagine they get stored in the <Application_Home>/Library/Caches, other content probably goes in Documents
You don't need to know what facebook or instagram do, but If I understand your question right, you want to download images asynchronously from web and cache them. For that u can use a third party class to handle the caching instead of writing your own, I would suggest SDWebImage.

HTML contents preloaded into an app and then updated from the Internet

The title says (quite) all: I would like to distribute an app with some HTML pages preloaded into the local Documents folder (they reflect the content of a mini mobile site available on the internet); then, when the contents of the pages are updated, the local HTML files into the app should be updated, so that the user can browse the updated informations also when not connected to the internet.
The app has to work since the first start, thanks to the preloaded pages, and then update itself periodically (I didn't need to check the modify date/time of the single files, it's enough to check and update them when the local copies are older than x days).
The problem: I think I can do it all, but I was asking to myself if is there some framework/class that does it automatically, because it sounds to be a pain :)
Consider using ASIHTTPRequest. Check out this SO question.
Specifically, you might want to look into ASIWebPageRequest:
download complete webpages, including external resources like images
and stylesheets. Pages of any size can be indefinitely cached, and
displayed in a UIWebview / WebView even when you have no network
connection.
I've also used AFNetworking for my own personal projects and it's made my life 10x easier. On the AFNetworking FAQ page, there's a question regarding caching mechanisms for offline viewing. It mentions that NSURLCache in iOS 5 introduced support for caching to disk for offline use - but only for http. If you need to cache https, consider using SDURLCache.
Here's a short additional resource in regards to network caching for iOS.
Read the section titled iOS network caching
If you are looking at pre popping your iOS app with the equivalent of a browser cache then
https://github.com/rs/SDURLCache might be something to look into.
It hooks in with existing NSURLConnection frameworks such as AFNetworking and you just need to set the correct cache policy in your NSURLRequest.
Given its open source you should be able to figure out how where to place your data so it loads it without fetching from the server the first time then just specify when you want the cache to purge itself so it fetches it from the server?

Offline webapp on iPad

I have a website written in php / javascript. It's quite simple, basically :
on the first page it shows a list of category
when a category is clicked, a new page is displayed with a list of pictures (that can be clicked to get a bigger version, using AJAX) and some text details
I'd like to be able to browse this site offline on an iPad, what would be the better way ?
I saw it is possible to add some html5 caching capability, would this be the way to go ?
You should try the HTML5's caching and/or persistent storage feature. You can save app data or even whole files, and either access them from JavaScript to display, or ask the browser to seamlessly display the cached files when there's no Internet connection. Some links may help:
http://www.html5rocks.com/en/tutorials/appcache/beginner/ <- this one is the caching-related
http://dev.w3.org/html5/webstorage/ <- and this is about persistent storage.
Hope that helps, Árpád

Issues with Filemaker IWP working with hyperlinks on images

I have a filemaker database that I need to be able to link records and all associated data (including container field data) to various points placed on a large PDF image, and then make that data appear via instant web publishing when someone clicks on the marker for that area on the PDF. For example the PDF may be an image of a car, and then I would have various close up images of issues with the car and descriptions of those images as records in the database. I would then want to drop points on the base PDF image and when you clicked on those points be able to see the close up images and other data related to those images.
I'm being told this is too much for IWP because:
I need to place the markers outside filemaker via PDF annotation
Filemaker IWP can't handle the number of markers that may be necessary (it could be up to 1,000 on an E sized image.
Does anyone have a work around or explanation why this is a problem?
If I understand correctly, you would like to setup a PDF with links that will open a browser and show data related to what was clicked. Assuming that is the case, the reason this wont work is because IWP does not provide a unique URL for a unique page. For example, here on StackOverflow you can directly link to any question based on its URL:
http://stackoverflow.com/questions/3207775/ -- this question
http://stackoverflow.com/questions/4973921/ -- some other question
IWP uses Javascript and session variables to manipulate the output to the screen, so there is no way to link to a specific section of your IWP site, since the URL is always something like:
http://yoursite.com/fmi/iwp/cgi?-db=YOUR_DB-loadframes -- Product A
http://yoursite.com/fmi/iwp/cgi?-db=YOUR_DB-loadframes -- Product B
http://yoursite.com/fmi/iwp/cgi?-db=YOUR_DB-loadframes -- Product C
Because of the limited nature of IWP, you will not be able to workaround this issue. You'll need to build your own web-interface using the Custom Web Publishing Engine, either using the built-in PHP extensions or some other technology where you invoke the XML publishing API.
I agree with Nate
IWP is the wrong solution to this problem. You'd be better off simply hosting those images on a webserver.
Now here comes the plug, you can use SuperContainer to really simplify the management of the images from FileMaker.

Resources