calling a method inside someClass from AppDelegate Objective-C IOS

前端 未结 3 527
后悔当初
后悔当初 2021-01-15 14:40

I\'m trying to call a method that\'s inside someClass from the AppDelegate class. I usually create an instance and then using that instance, call the method. Like so:

<
3条回答
  •  伪装坚强ぢ
    2021-01-15 15:07

    Instantiate an instance of the class that you want to send the request from and make the method public (in the .h file). Then import that class into the app delegate and call it.

    Like so...

      YourClass * yourClassInstance = [[YourClass alloc] init];
      [yourClassInstance someMethod];
    

    in YourClass.h below the @interface you would declare the method like so

     -(void)someMethod;
    

    So anyone could access it.

提交回复
热议问题