0

My code works and lets me pick a image from some kind of default saved camera roll that apple has built in on the computer. If I understand it right - whenever a person would use my app they would of course have it connect to their personal phone.

My question is: I'm trying to test my app using photos from my computer instead of the default photos that apple provides (landscapes and pictures of waterfalls). Is there a way I can directly access a folder on my desktop when I click my browse files button (btnClicked) and pull a picture out of there?

Here is what I'm using right now. How can I manipulate this to do what I need?

// Custom Image
    var imagePicker = UIImagePickerController();

    @IBOutlet weak var imageView: UIImageView!

    // Button Clicked for Image
    @IBAction func btnClicked(sender: AnyObject)
    {
        if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.SavedPhotosAlbum){
            print("Button capture")


            imagePicker.delegate = self
            imagePicker.sourceType = UIImagePickerControllerSourceType.SavedPhotosAlbum;
            imagePicker.allowsEditing = false

            self.presentViewController(imagePicker, animated: true, completion: nil)
        }
    }

    // View Did Load
    override func viewDidLoad()
    {
        super.viewDidLoad();
        // Do any additional setup after loading the view.

        // Set the User's "Hairstyle"
        userHairStyleLab.text = HairStyle;
    }

    // Did Receive Memory Warning
    override func didReceiveMemoryWarning()
    {
        super.didReceiveMemoryWarning();
        // Dispose of any resources that can be recreated.
    }

    func imagePickerController(picker: UIImagePickerController!, didFinishPickingImage image: UIImage!, editingInfo: [NSObject: AnyObject]!){
        self.dismissViewControllerAnimated(true, completion: { () -> Void in

        })

        imageView.image = image

    }
Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Yusha
  • 53
  • 7
  • Not clear. You want to read computer files from the iOS simulator? Then no it is not possible of course. But you can add any pictures you want in the simulator. – Jean-Baptiste Yunès Apr 22 '16 at 08:50
  • You're telling me that it's not possible for the user to browse their mac directory to upload a picture? How is that? In C# / C++ we can easily access a folder on the desktop to allow the user to upload a file / and or picture. – Yusha Apr 22 '16 at 16:23
  • I'm just trying to figure out (for the purpose of testing and presenting my app) to someone, is it possible then, to plug in my iphone and like "simulate" my app such that I can upload a photo from it in the simulator? It's ridiculous to me that they wouldn't allow such a feature, I mean what are applications on the mac even made in if not swift/objective c? Because surely apps on the mac have browse features and folder dialog view of files – Yusha Apr 22 '16 at 16:25
  • 1
    You are using UI classes, so your are writing iOS app, why would you the simulator to let you open file on your desktop mac? If it would let you make this, then it will not be a simulator in any way, as you can't "open a file on a mac" from an iOS device (non sense). Read this http://stackoverflow.com/questions/468879/adding-images-to-iphone-simulator to simulate a more realistic usage scenario. – Jean-Baptiste Yunès Apr 23 '16 at 07:35

0 Answers0