3

I'm following the "Getting Started with IOs Swift Apps" program on developper.apple.com and can't click and drag an object to the ViewController. This question has already been asked and answered with apparent great success but I can't find the .h or .m file almost each answer is talking about.

Here is what I can see when I check the viewcontroller file.

viewcontroller

Do you have an idea on how I can select or write a .h or .m file? There were also some answers about classes but I don't understand how to do this. Here is the Q&A link: Can't drag and drop item from storyboard to viewcontroller in xcode

Thank you for your help!!!

  • thanks @Codus and so sorry I don't understand the step to fulfill. Here is what's described by Apple for developers "Below the class line, add the following: //MARK: Properties [...] In your storyboard, select the text field. Control-drag from the text field on your canvas to the code display in the editor on the right, stopping the drag at the line below the comment you just added in ViewController.swift." – Alice Chagnaud Jul 12 '17 at 12:59
  • .h and .m files are for Objective-C. As you are using Swift, the equivalent file you added is .swift – Lawliet Jul 12 '17 at 12:59
  • Did you hold the **control** key while dragging the views? – Lawliet Jul 12 '17 at 13:02
  • Thanks @Lawliet. I should add .swift at the end of the ViewController Class? If so, I tried and did not work. Name could not be changed. – Alice Chagnaud Jul 12 '17 at 13:03
  • You don't have to add anything in. The extension is there by default. – Lawliet Jul 12 '17 at 13:04
  • It's working @Lawliet !!!!! Thank you so much and sorry for this stupide missed step. I now hold the control key – Alice Chagnaud Jul 12 '17 at 13:04
  • No worries, well done! – Lawliet Jul 12 '17 at 13:07

2 Answers2

1

As per your attached image, you are working in the swift so no need to add .h or .m file in the "Identity Inspector".

As per your attached image, you just selection "View Controller" and first closed you "Assistant Inspector" screen and again open "Assistant Inspector". Now long press and drag you pointer to the "View Controller" which is shown via "Assistant Inspector" which was shown in your attached image.

NOTE: Please drag drop you cursor outside the method "ViewDidLoad". It may be possible you have drag drop your pointed Label or button in this method so its not show any outlet declaration popup.

If not understand the solution so please provide more details.

Thanks,

  • 2
    Thank you very much for your help, I made the basic mistake of not pressing the ctr key while dragging and dropping. Now it's working. – Alice Chagnaud Jul 13 '17 at 14:24
1

Do not forget to hold the Ctrl key while you are dragging

shmakova
  • 6,076
  • 3
  • 28
  • 44