Is there any limit of file size in the Document of IOS app - iphone

I want to write a app to download and manage files from the web.If I just put the file in the Document. Is there any limit of file size or can I load another app to read the file in the Directory?

I don’t think there is a limit to how big a file you can put in your app’s Documents directory other than the amount of free space left on the device.
No, other apps cannot access the contents of your app’s Documents directory—that’s the entire purpose of the sandboxing system. What you can do is use the UIDocumentInteractionController class with a file you’ve downloaded to present the user with a list of apps that can handle opening that file.

The filesystem would limit the size to 4G, but im sure the iOS limits it even further.
No two apps can see each others files, unless the user export/import them via iTunes, or you set the app to be in the list of options when you hold down the link and the "Open In..." popup appears.
Check out the UIDocumentInteractionController Reference.
And UIActionSheetDelegate Reference.

Related

Is there a path every app can write files in the jailbreak iPhone?

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?

how can i do Limit the file app size in ipad?

I want to write a app to download and manage files from the web. If I just put the file in the Document. Is there any limit of file size in the Directory?
can any one help me..
thanks in advance.
Just a warning with the introduction of iOS5 saving large files or files that can be regenerated into the documents directory is frowned upon (actually you were never meant to do it but its only being enforced now). This is because the files in the documents directory get backed up to iCloud and you obviously do not want to fill that up. Apple have started rejecting apps just for this reason.
You should now place the downloaded files into the temp or cache directories. But also be aware that the OS will clear these directories when running low on memory so you need to have logic in you app to check if the files exist and re-download if they do not.
No real limit except the device and other user data. Still best to be frugal.

file browser in iphone?

I am new to Iphone.How to create file browser in iphone ?
I wish to show all the files and folders in the iphone.How to do this?
Unless you are on a jailbroken phone, your app can only access files within its own "sandbox".
There are three folders your app can access, which contain data specific to your application. Your app will not be able to access file data outside these folders.
With that caveat in mind, you would likely use:
NSFileManager and NSDirectoryEnumerator to build a data source to a table view
UITableView to present the list of files and folders obtained from step 1
UINavigationController to provide a navigation stack for walking through a hierarchy of folders: a stack of UITableView instances
to browse the list of accessible files and folders within your application's sandbox.
If you are producing this for the App Store, I would suggest against exposing such a control even for your application's data. It violates the Human Interface Guidelines and most likely will be rejected.
From the iPad Human Interface Guidelines:
Although iPad applications can allow
people to create and manipulate files,
this does not mean that people should
have a sense of the file system on
iPad.
On iPad, there is no application
analogous to the Mac OS X Finder, and
people should not be asked to interact
with files as they do on a computer.
In particular, people should not be
faced with anything that encourages
them to think about file types or
locations, such as:
An open or save dialog that exposes a file hierarchy
Information about the permissions status of files

Is Library/Caches cleared automatically by the iPhoneOS?

I have an app that will need to cache some images.
I have read some documentation about caching, and the logical thing to do is to cache my images within the Library/Caches directory within my app's sandbox.
I understand that the reason for storing caches images here are:
Library/Caches isn't backed up by iTunes
Library/Caches is cleared periodically by the OS
That second point is what I'm questioning...
Is this true?
Does the OS clear the caches directory automatically?
Will I need any of my own logic to detect if the cache is too big and to clear the oldest items?
I found this in the documentation:
Use this directory to write any application-specific support files that you want to persist between launches of the application. Your application is generally responsible for adding and removing these files. However, iTunes removes these files during a full restore of the device so you should be able to recreate them as needed. To access this directory, use the interfaces described in “Getting Paths to Application Directories” to get the path to the directory.
In iPhone OS 2.2 and later, the contents of this directory are not backed up by iTunes.
http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/FilesandNetworking/FilesandNetworking.html

How can you access a set of photos with the iPhone SDK?

I know that I can access the camera or show the image picker to the user, but what if I just wanted to pick 10 photos, randomly, from the images stored on the device with no user interaction?
Using UIImagePickerController gives me the ability to use the camera or the image picker, but how can I do this automatically, without user interaction?
AFAIK there is no way of accessing any files from any Apple app (or any other app for that matter) unless you use one of the classes provided by the SDK.
I once wrote a simple browser app that starts at / and populates a UITableView with the contents of the directory. It let me see what directories I could access, and what files I could access within those directories. If you can find what you're looking for, help yourself to it's directory contents. Otherwise, it may be hidden from you, inaccessible from your application's sandbox.