IOS method call

I have a method that I need to call in another method. in UIViewController

//This is how i call methoed tmpUITextView.text= [self ssidValue:1 arrayOf:ssidArray]; //my Method + (NSString *)ssidValue:(NSInteger)selectedValue arrayOf:(NSMutableArray *)tmpArray { NSString *result=[tmpArray objectAtIndex:selectedValue]; NSLog(@"%@",result); return result; } 

but I get waring (warning: "UIViewController" may not respond to "-ssidValue: arrayOf:") and break it.

Please tell me what I'm doing wrong here.

Thanks at Advance

+4
source share
3 answers

You declare a method as a class method (note the "+"), but you call it as an instance method.

To solve this problem, declare it as an instance method (replace "+" with "-") or name it as a class method:

 [[self class] ssidValue:1 arrayOf:ssidArray]; 
+17
source

use the declaration of the instance method type ie ,. use "-" instead of "+" to declare a method and you can call it using the class name

  tmpUITextView.text= [class_Name ssidValue:1 arrayOf:ssidArray]; 

class_name is the name of the class. Where is the method initialized

0
source

You declare a method as a class method (note the "+"), but you call it as an instance method.

To solve this problem, declare it as an instance method (replace "+" with "-") or name it as a class method:

 [[self class] ssidValue:1 arrayOf:ssidArray]; 
0
source

All Articles