Accessing Method from other Classes Objective-C

前端 未结 8 1537
挽巷
挽巷 2020-11-29 05:57

Looked for an answer for this question, but I haven\'t found a suitable one yet. I\'m hoping you guys (and gals) can help me out! (This is for an iPhone app)

Alrig

8条回答
  •  鱼传尺愫
    2020-11-29 06:45

    Pass in a reference to your commonClass when you alloc and init your views...

    CommonClass *cc = [[CommonClass alloc] init];
    
    ViewController1 *vc1 = [[ViewController1 alloc] ... initWith:cc];
    ViewController2 *vc2 = [[ViewController2 alloc] ... initWith:cc];
    

    but making a classic c include might suffice.

提交回复
热议问题