Using an object instead of AppDelegate for Outlets & Actions?

In all MonoTouch examples, I saw that everyone uses the weekend and actions in AppDelegate, but when I went through several objective-C webcasts, I see people using the object that they drag onto the XIB in Interface Builder and using it (it seems a lot cleaner). Is there a way to reference any objects that we create? Is there a way to access it?

Any advice would be appreciated,

thanks

+4
source share
2 answers

Sure.

  • Drag the object to xib in Interface Builder.
  • Set the type for what you want for the class name in the "Identity Inspector" section of the "Class Identifier" section.
  • In the "Classes" section of the library, select your class and add the desired outputs.
  • Add the user interface objects and connect the outputs from the instance you added to xib, as usual.
  • Add your class to MonoDevelop and make it an incomplete class derived from NSObject.
    • The output will be in the generated part of the partial class in the .designer.cs file for xib
  • Add code to your class to interact with outputs pointing to objects added in Interface Builder

I added a small sample here , which creates a class called "SomeClass" that is created via xib, as well as an output to UILabel, with the text for UILabel installed in the SomeClass file that I added to MonoDevelop.

+3
source

There is no other way to access objects from Interface Builder. Even for this object, an output for connection is required.

0
source

Source: https://habr.com/ru/post/1340461/


All Articles