IOS方法调用
我有一个方法需要在另一个方法中调用。在 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;
}
,但我正在警告(警告:“UIViewController”可能不会响应“-ssidValue:arrayOf:”)并使其崩溃。
请告诉我我在这里做错了什么。
提前致谢
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 ( warning: 'UIViewController' may not respond to '-ssidValue:arrayOf:')and crash it.
Please tell me what i am doing wrong here.
Thanks in Advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您将该方法声明为类方法(注意“+”),但您将该方法作为实例方法调用。
要解决此问题,请将其声明为实例方法(将“+”替换为“-”)或将其作为类方法调用:
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:
使用实例方法类型声明,即。使用“-”代替“+”进行方法声明
您可以使用类名来调用它
class_name 是方法初始化的类的名称
use the instance method type declaration i.e.,. use "-" instead of "+" for method declaration
and you can call it using the class name
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: