cannot call static method from MainViewController from CDVPlugin class objective c and phonegap

StackOverflow https://stackoverflow.com/questions/20841316

  •  22-09-2022
  •  | 
  •  

I need to call static method from MainViewController to add Progress Bar, this progress bar show downloading progress from connection object in CDVPlugin class.

I make static method in MainViewController like:

+ (void)CommonMethod
{}

and defined it in MainViewController.h too like:

+ (void)CommonMethod;

I want to call it in class which is inherited from CDVPlugin, it's a bridge with javascript side.

I call it by two ways: 1-

MainViewController *mainView = [[MainViewController alloc] init];
[mainView CommonMathod];

OR 2-

[MainViewController CommonMathod];

But, the two was result this warning which stop all of my app completely.

instance method '-CommonMethod' not found (return type defaults to 'id')

What can I do ?

Thank you in advance,

有帮助吗?

解决方案

Try this..

[[MainViewController class] CommonMethod];

it is helpful

其他提示

Need

#improt "MainViewController.h"

And call with

[MainViewController CommonMathod];
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top