amt amt - 5 months ago 19
Objective-C Question

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

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,

Answer

Try this..

[[MainViewController class] CommonMethod];

it is helpful

Comments