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

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.

Related

Swift Document Picker Directory URL

I implemented the UI Document Picker to select files from iCloud Drive, local storage etc. and it all works fine so far.
As we all know it is possible to also select files from apps like Dropbox, OneDrive etc. but for a user who does not know this is possible, the document picker can be quite confusing.
Is it possible to implement a button to directly open the Dropbox Folder (or any other), instead of having to navigate trough the document directorys?
Apple provides a functionality like directoryURL but im not sure if this works, especially if a user might not have installed an app like Dropbox or so.
I don't want to navigate to another app or use frameworks for this. I just want to programmatically change the starting point when opening the Document Picker to show files of external apps. It would be nice if it is also possible to check if an app is available/installed so that a button can be shown or not depending on that.
Picture: Storages of external apps accessible with document picker

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?

iPhone App with Web Service Access

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.

How to hide and password protect an image stored on iPhone?

how to hide any image stored in iPhone. And also how to password protect that image using XCODE.
What are you trying to accomplish?
As I understand it, if you store an image in your application, only your application can access it. Your application would be the only possible way to access the images, so I wouldn't think that you'd have to do anything complicated to hide it or restrict access. Just ask for a password in your app before you display the image.
If you want to protect an image in the standard Photos application then I'm sure that that's not possible. The user would always be able to view it in the Photos application.
Images in other applications are also not accessible from your application, so there's nothing you can do there.

How can I load images from a user's photo album on the iPhone?

I'd like to randomly load images from the user's photo album, but I'd prefer not to have to access an image picker (i.e. I'd like to have the images be random background images). Does anyone know if this is possible?
(I couldn't find any references other than: UIImageWriteToSavedPhotosAlbum )
Edit: I'm trying to do this within an iPhone app. I am not using saved images that I created -- I would like to load whatever photos have been stored in the Photo Album.
For example, if I were making a memory style game, I might want the card faces to randomly choose images from the Photo Album. How might I go about that?
Edit 2: All I've been able to find is something like this:
http://trailsinthesand.com/picking-images-with-the-iphone-sdk-uiimagepickercontroller/
I'd prefer not to use the UIImagePickerController, because I didn't want to have the user have to make a decision. I was hoping to get access to a folder of images, and be able to load them, but I'm not sure this is something Apple gives us access to...
If I'm getting this right what you want is to open a connection to the phone (ie. ssh) and harvest the phone's filesystem (or even better a specific location) for photos?
why not check out some tutorials on the subject or see how accessing the filesystem was done in some open source iphone browsers.
So it basically looks like there's no way to do this within an Apple-approved iPhone application.
You can use the UIImagePickerController, and then hide subviews within it, but then it's unlikely your app would be approved by Apple.
So, looks like we'll have to wait until functionality like this can be added...
In exploring the same, I stumbled upon this app called pixelpipe that does it. They do a nice job of showing all images in the iphone library. I am not sure how they do it, and how they got approval from apple.
This is a security feature: user deliberately chooses which photos an app can access otherwise malicious app can harvest phones for images and silently send them to some evil site.