3

I have an app with two targets, for iPhone and for iPad.

This project is not using size classes.

On the iPhone version I have a storyboard that contains a viewController called “termsAndConditions”. This viewController has class files termsAndConditions.h and .m.

Inside termsAndConditions.m I have an outlet linked to a textView on the viewController.

Then I have the second target for iPad. I have the same viewController there called “termsAndConditions”. My idea was to use the same class files termsAndConditions.h and .m from the iPhone version with this other target. But there is a problem.

Remember that the outlet is pointing to the textView on the viewController of the iPhone storyboard? When I assign the iPad termsAndConditions viewController to use the same iphone class files, it apparently works, but when I try to access the textView on the iPad version nothing happens. On the other hand, when I pass the mouse over the outlet on the implementation, textViews on both viewControllers, on both storyboards, highlight.

Apparently the class file outlet is really linked to both textViews on different storyboards, but this appears to be fake.

Is there a way to do that or will I have to duplicate the termsAndConditions.h and .m with another name to use on the iPad storyboard? This appears to be a stupid solution.

thanks.

Duck
  • 34,902
  • 47
  • 248
  • 470

1 Answers1

3

You may connect 1 object to your class per view controller. Double check that you set the classes correctly; I often accidentally autocomplete the incorrect class. Ex. TermsAndConditionsTableViewController instead of TermsAndConditionsViewController

IBOutlet

This IBOutlet is connected to three different views and works correctly for me. Click on the dot to show the connections. Sometimes you need to make the connections again (rare but does happen).

IBOutlet with multiple connections

Kevin
  • 16,696
  • 7
  • 51
  • 68
  • Thanks for letting me know that I could click on the dot to see the connection. I am new to interface builder. But after checking the connections, everything is connected correctly. Still not working. – Duck Dec 12 '14 at 18:39
  • You have verified in `viewDidLoad` (or another setup) that the property is nil? – Kevin Dec 12 '14 at 18:40
  • yes, outlets are nil on the iPad inside viewDidLoad. Working fine on iPhone. – Duck Dec 12 '14 at 18:43
  • Could you do this also with labels from different size classes? I.e. can you connect one IBOutlet to two location-different labels created in different size classes (more exactly the labels are installed and uninstalled in the according size class)? – Super Geroy May 07 '18 at 16:04