What I'm building is simply an application that fetches data over the web and displays them on the iOS views. Data are text and, sometimes, images / music files / movies.
I'd like to use some caching solution for the media. What it needs to do is:
get an url of the file
check if it's alredy downloaded in the cache storage, if it is, serve it
if not, download it
while also checking how much of the storage the current cache uses, and, if it's over the quota, delete oldest files
Best would be to have a simple interface for this - so I can just give an url and get the file of it (while files can change over time and reside on the same URL, so this should be handled too, in a perfect case).
Anyone knows a library to do it, on iPhone/iPad application?
ASIHttpRequest has a DownloadCache option that may work for you. From their documentation:
* You want to have access to the data when there is no internet connection and you can't download it again
* You want to download something only if it has changed since you last downloaded it
* The content you are working with will never change, so you only want to download it once
This is what I used in my iPad app and it works pretty well.
You could try looking at using a UIWebview for the view. If I am understanding this correctly, you will be hosting your content on a web server and would simply like the iOS device to pull the content from the URL. This is what UIWebview is. It is essentially programmable access to Safari.
Related
My app uses a-lot of cached images which (I think is the reason causing my app to crash) when i scroll to view so many at one time.
My app is all about images inside list/grid view.
Is it good practice to cache them all?
Note:
Please note I'm using SliverGrid which is loading images lazily.
If you going to manage a buch of amount image is better, download them to a local directory and take the url like a name in a Data Base then you can ask on every request if your url is on your data base if is there then the file in your directory exist if not, you do the request and store it file in directory and name on db. This is better when your app manage a buch of information in cache like image, because on some devices the app can be crash o even restar the device.
I should hook UIResponder of every app, including SpringBoard and any others. In the hooking, I will write something to the specified file. If I set the path to /var/mobile/Library/MyApp, recommended by Cydia, I found that only the SpringBoard and MyApp could write successfully.
So is there a place every app can write and read?
I admit that I'm not 100% sure on this one, but my guess would be no, there is not a path that every app can writes files to on a jailbroken iPhone.
Certainly, jailbreak apps (installed in /Applications/) on a jailbroken phone can write to locations that can be shared between those jailbreak apps. But, as I understand your question, you would like to inject code into normal, App Store apps, so that those apps can also read and write to the shared location. That part I don't think is possible, because jailbreaking does not completely disable the sandbox for 3rd-party apps installed normally, under /var/mobile/Applications/.
Now, there might be a workaround. There are some shared folders that are accessible to all apps for certain purposes. For example, any app can write images to the saved photos album. What you could try is to take the content of the file you want to write, and encode it as fake image data, in a UIImage (e.g. with [UIImage imageWithData:]). You'd probably need to add a valid image header to the data. Then, you save the file to the photos album, using something like
writeImageToSavedPhotosAlbum:orientation:completionBlock:.
Another app could then find the fake photo by enumerating the saved photos album, and then converting the asset back to image representation to pull the real data back out.
However, this seems quite complicated, and possibly wouldn't work (I haven't tried it). Perhaps you could tell us why you want this shared file. Maybe there's a better way to share the data, without using a globally-accessible file?
Notifications can help you with this. Every app will send interprocess notifications about the events. You could start a daemon that will listen for this notifications and save them in a file. Or you could listen for them in SpringBoard as he can write, for example, to /var/mobile/Media. Depends on what you want to do with this file. Check out my answer here How to create a global environment variable that can be accessed by SpringBoard or other applications in the jailbroken iPhone?
I am new to iphone development. I would like to know how to do the caching in ios 4 and above??
I got many answers but right now I get confused and don't know from where to start.
In my project, I am doing http request and displaying results using UIWebView
Here,I want to cache the http data. So next time when application starts again then It will reload the data from the cache.
how to cache the webpage data in IOs 4 and above?
I have done with caching of whole web page using ASIHTTPRequest. I go through the ASIHTTPRequest: here is a link to it.
You will have to make use of Core Data to store your data locally by modeling your data in it. You will need to go through the core data programming guide: here is a link to it.
http://developer.apple.com/library/mac/documentation/cocoa/Conceptual/CoreData/CoreData.pdf
After you have understood for how to store your data, you will able to easily able to load this when your app starts the next time.
Im not sure of how to store the web view's data as an html page locally, though that can be an alternative approach too.
I hope it helps you!!! Cheers!!
I want to show some really simple graphics in a http-page in the local network using an iOS App as local server.
Now I heard showing some http-page over the local network is quite easy, using for example CocoaHTTPServer.
Would it also be possible to adjust the content of the page dynamically, from the iPhone side?
Meaning
user types in URL at the desktop-pc-browser of his choice
user goes to his sofa, flicking through text/images with his iPhone, looking at the remote screen
(no need to go to the browser to refresh page?)
Would this be feasible?
Of course I could also try to set up some Bluetooth-Connection, connecting between iOS/MacOS Apps, but I figured the browser version would be much more flexible :)
Stable connection? No need to support each and every browser? Then open up a websocket connection between your app and your browser. You’d then advise your browser to reload or show another picture through the websocket.
If you need to support more browsers, you might need comet / long-polling support. I’m not sure, though, whether CocoaHTTPServer supports it.
If none of these work, you could have your webapp do an Ajax request every now and then, in order to check whether something has changed.
I have been asked to write a compliment website/service for an iPhone app.
The app creates images. The author wants these images to be uploaded onto the server, into their personal storage area. These images need to be able to be pulled down to the iPhone later for editing. The user will be able to use the website as well to see these images.
I have yet to decide (or understand) what the best way of implementing this would be. And with no experience with iPhone development I have no idea what it can actually handle.
Uploading and downloading images is trivial using NSURL and associated classes. You just open the URL, write/read the file and you're done.
See The URL Loading System to get started.