Using object from one class in another

后端 未结 1 1811
别跟我提以往
别跟我提以往 2021-01-15 01:24

I have a two UIViewControllers, on one of which I want a custom button to be displayed. I have written the code for this. I have also written the code for a pop

相关标签:
1条回答
  • 2021-01-15 02:05

    I have a two UIViewControllers, on one of which I want a custom button to be displayed. I have written the code for this. I have also written the code for a popover segue to the other ViewController, and as both controllers are subclasses of my 'ViewController' class, the button is also displayed on the second ViewController, which I do not want.

    Why don't you make few property private in first cass so that it doesn't get inherited.


    Obviously I can create another class and make my second ViewController a member of this class, however I want the code for my second ViewController to change the colour of the button in the first ViewController, so how can I use an object from my first class in the second class implementation file?

    Your main problem is to access object of ClassA from ClassB.

    Here are a lot of ways, and answers here, to do :

    Update a label through button from different view

    Xcode - update ViewController label text from different view

    Setting label text in another class

    Set label on another view to stored NSDate

    0 讨论(0)
提交回复
热议问题