Creating a file browser - iphone

I need a file selector in an iPhone application I am developing to select a file to encrypt? Any idea how I would go about accessing files on the iPhone?
It would be something like this: http://iphone.heinelt.eu/?Applications:iFile:File_Browser

If you’re making a file browser, you’re probably taking the wrong approach. The design philosophy of iOS—and the Human Interface Guidelines—strongly recommend that you not expose the filesystem unless you really, really have to. Generally, collections of documents in iOS apps are displayed as a flat list—witness the built-in Notes app as well as Apple’s own iWork (Pages / Keynote / Numbers) suite. You can display that list in a UITableView, which you can find plenty of documentation about and tutorials for by Googling it.

Related

What Files can iOS Apps use?

The situation: We would like to make an app that shows all files on an iOS Device
The system: iOS App, non jailbroken system
The question:
What files (and filetypes) are allowed to be accessed by every app (system-wide) ?
(PS: we won't do file-browser like actions like sub-folders, delete, etc .. )
UPDATE :
what you are trying to achieve is not possible because of the sandbox feature of the apps. though you can display certain file types using below description.
Previously Answered this
If I understand your question correctly, there is already a framework for what you are trying to achieve. It is called the quick look framework and supports these many file types...
A Quick Look preview controller can display previews for the following items:
iWork documents
Microsoft Office documents (Office ‘97 and newer)
Rich Text Format (RTF) documents
PDF files
Images
Text files whose uniform type identifier (UTI) conforms to the public.text type (see Uniform Type Identifiers Reference)
Comma-separated value (csv) files
you can have more info about it here...
You can't access anything other than your application folder. Your application is sandboxed and for good reasons (privacy, malware, etc...)
You can only access files within your application directory. Look here for a full explanation
If you don't mean files and just the content of the phone, there are APIs for
Photos
Contacts
Media from the Music app

Is there a way to convert epub format to images?

I need a tool to programmatically convert epub files to a series of images. The output should look like screenshots taken on a canonical device (for this application, an iPad). I haven't been able to find any tools that do something like this.
So what I'd really like (1) is a tool that does that. But assuming that I'm correct that no such tool exists, is there (2) a library (preferably a Perl module, but I'm not that picky) that will read and render ePub?
Obviously, rolling my own I could combine tools for unzipping, reading html, reading xml, putting everything in the right order, and rendering html within certain constraints. Though I'd rather not do that, and if that's the only option I'll have to go on to look for a tool that will do the last part of that or I'll have to create that too.
Any leads on (1), or failing that (2)?
Apologies if what I'm about to type is just crazy-talk on my part--in fact, I'm pretty sure it is--but perhaps something like this might work and I'm kind of interested in knowing how well it might work for you:
Use Frank (https://github.com/moredip/Frank) to control the iOS Simulator on a Mac. Program it to open up the EPUB docs you need.
All you need then is something to automate the taking of the screen shots. Obviously, these will look like the EPUBs are being rendered in an iPad (or an iPhone if you wish--the iOS Simulator does both, of course).
Automating the screenshots can probably be done with AppleScript, although the hard part might be getting it to talk to Frank. Worst case, you can tell Frank to pause for 5 seconds after it loads each page and tell AppleScript to take a screen shot every five seconds. That sucks, but if you're desperate, it will get it done. It's also possible Frank can somehow make the screenshots happen--I haven't used it enough to know.
Pandoc can convert from EPub to LaTeX (and therefore to PDF) or to any number of other formats. Conceptually this should be a type (1) solution.
depends on your definition of "look like" - do you want the user-chrome or just the epub rendering for a given screen size.
I would check out the various epub readers for your platform of choice, size the window to your preferred dimensions, and then just "print" the epub to a virtual printer that outputs to image files - on windoze I use imageprint.
You could easily make a "frame" from an iPad product shot and place your screenshots within that - only thing missing would be as I said the user chrome.

How do I open a file with unknown associations in iOS?

I think it's rather impossible, but will ask anyway. My application uses file association to open some types of files. What I need is to make file associations within my app. For example I have some files in my app's Documents folder and when user wants to open that it would be a great idea to ask him in which application he would like it to open (like Mail app does).
It can possibly be done with URL schemes, but if I don't know what applications user has, it can't be used. So, is there any way to use the device's file associations within an application?
You should take a look at Document Interaction Programming Topics for iOS. It explains how you can use the UIDocumentInteractionController class to present the user a list of apps which support a given file.

How can I edit PDF files in an iOS application?

In my iPhone / iPad application, I show a person's medical reports in the form of a PDF. I have saved the reports in the documents directory and am reading them from there.
I want the user to be able to add or edit comments on these PDFs, as well as be able to highlight certain sections in the PDF. After editing, the application should be able to save the PDF back into the documents directory.
Is this possible within an iOS application? If so, how? Is this a task for Core Graphics?
Editing PDF directly on iPad/iPhone is a rather big job because the standard API only supports showing it (and only a bit more.) If you want to do anything more, you need to invest a huge amount of time to implement generic pdf handling code.
There is an open-source library handling these, e.g. this one. I don't know if it fits your needs, though.
A better idea, in my opinion, is to create a native UI showing the data contained in the PDF file using the standard Cocoa-Touch UIKit and create the PDF once the user is done with it so that the user can export it back. That way, you don't have to write a complicated PDF handling code.
In any case, it's not a good idea to show generic PDF on iPhone, because the screen size is so small (iPad is a different question, especially if you expect the user to be familiar with the particular format of your pdf.). A dedicated UI would be much better.

Adding PDF to iBooks by code

I was recently asked if I could code a simple IPhone/IPad app that:
Checks an FTP server for changes to a PDF file (easy)
Downloads the lastest PDF (easy)
Adds or replace the file on iBooks (hmm...)
I have tried to find any code that deals with inserting/adding/updating files inside iBooks, but sadly there is very little on the subject. Is this even possible except manually through iTunes? My gut feeling says that it's just a matter of writing the file to a folder..
It makes sense if it were such an API. There are many companies that would like to keep their product portfolios up to date, or research manuals that (in theory at least) could benefit greatly from being updated automatically through an app.
Any help or comments are welcome.
My gut feeling says that it's just a
matter of writing the file to a
folder..
Unfortunately, this probably isn't the case. I'd imagine iBooks using some sort of database to keep track of books, rather than simple files.
There is a URL schema for iBooks, but it's undocumented, and nobody has found any methods that would update/replace a book (I don't know if any even exist): How do I launch iBooks e-reader programmatically on iPad?
If you feel this is something that would be beneficial to iBooks, you should consider filing a feature request on the Apple dev site.
UIDocumentInteractionController is your friend in this case