Link IBOutlet.

Discussion in 'iOS Programming' started by rich1812, Nov 5, 2018.

  1. rich1812 macrumors member

    Joined:
    Oct 4, 2015
    Location:
    earth
    #1
    Hello, it's been quite a while since I did an iOS app. right now I use xCode 10.1 I follow this tutorial https://medium.com/@rizwanm/https-medium-com-rizwanm-swift-camera-part-1-c38b8b773b2.
    One of the most annoyiny things in xcode is linking the buton. In step 2 of the tutorial, it says "
    Control + drag our preview vie to ViewController.swift and create an IBOutlet named previewView". How do I do that? It seems no matter how I control drag, it never create an IBOutlet.
     
  2. PhoneyDeveloper macrumors 68040

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #2
    You need to have the storyboard and ViewController.swift both visible side by side. Control click on the view in the list of views and drag into the ViewController.swift file inside the ViewController class. You should see a blue line appear indicating where the outlet will be placed. Release the mouse and a little window will appear. Type in the name and close the little window. It should insert the IBOutlet.

    There are other ways to do this but that's probably the most convenient.
     
  3. grandM macrumors 65816

    grandM

    Joined:
    Oct 14, 2013
    #3
    You can put the storyboard and ViewController.swift next to each other tapping on a button on the right hand top. If another file appears option click on ViewController.swift.
     

Share This Page