Need help with UIImagePickerController

Discussion in 'iPhone/iPad Programming' started by lynkynpark86, May 21, 2011.

  1. macrumors 6502

    #1
    I am making an app that will require UIImagePickerController. Here's the problem: I need to fetch the file path, or at least the name, of the image selected. Any ideas on how to do this? It will be a jailbreak-based app.
     
  2. macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #2
    I googled that couple days ago instead of making posts, and I found it within 10 minutes, but doesn't work if u want to keep on doing something after that. with that file path, because of what it returns.
     
  3. lynkynpark86, May 22, 2011
    Last edited: May 22, 2011

    thread starter macrumors 6502

    #3
    I will admit I am horrible at google searches, but I do actually try first. I googled "iPhone SDK UIImagePickerController file path", "UIImagePickerController string", "UIImagePickerController NSURL", and like 4 others. What did you search? I never post before at least 10-15 mins of searching. Could you post some idea of what you searched?

    EDIT: I think I found what you are taking about (/var/mobile/Documents/Image.png). Is there a way to get the actual image path (/var/mobile/Media/DCIM/100APPLE/IMG_0001.PNG)?
     
  4. macrumors 603

    Joined:
    Aug 9, 2009
    #4
    I started by reading the class reference doc for UIImagePickerController.
    Search terms: UIImagePickerController class reference

    Reading that doc, it doesn't take long to figure out there's a delegate who receives messages when the picker is dismissed. That delegate implements the UIImagePickerControllerDelegate protocol. There's a link to its reference doc in UIImagePickerController's class reference, so no search terms needed, just click the link.

    Once in UIImagePickerControllerDelegate Protocol Reference, the obvious method of interest is:
    imagePickerController:didFinishPickingMediaWithInfo:

    Reading its description for the info dictionary, we see this:
    The keys for this dictionary are listed in "Editing Information Keys."
    where the quoted words are a link. So again, click the link and start reading.

    Two of the keys contain the pattern "URL", and reading their description clarifies what each URL refers to.

    At that point, writing some test code would be in order, using NSLog to print the URL to console and see if it contains the file URL of the original image. If you don't get the answer you hoped for, then you'd post your code here, along with a description of what you're trying to accomplish.


    So the basic strategy I always start with isn't to randomly try keywords in google, but to use the specific keywords class reference with the class name.

    Since the class reference docs are also available as part of the SDK docs in Xcode, you should be able to read the same thing there, without having to be online or using a browser.

    The other thing to realize is that pathnames in iOS are sometimes represented as URLs, even when the target resource is a file, so searching for "pathname" or "file path" may not produce any useful results. Again, starting at the class reference doc and searching it for words like "path" or "file" or "URL" is likely to be more productive.

    If delegates are involved, you almost always have to search their reference docs likewise. In this case, UIImagePickerController doesn't say anything about URLs, but UIImagePickerControllerDelegate certainly does.
     

Share This Page