开发者

IOS Method Calling

I have a method which i need to call within another method. in a 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 am getting waring ( 开发者_Python百科warning: 'UIViewController' may not respond to '-ssidValue:arrayOf:')and crash it.

Please tell me what i am doing wrong here.

Thanks in Advance


You are declaring the method as a class method (note the "+") but you are calling it as an instance method.

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

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


use the instance method type declaration i.e.,. use "-" instead of "+" for method declaration 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 Wherethe method initialized


You are declaring the method as a class method (note the "+") but you are calling it as an instance method.

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

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜