开发者

How to call a selector in a different class

开发者 https://www.devze.com 2023-01-19 07:28 出处:网络
开发者_运维知识库How would this code be different if the method was in a different class? [saveButton addTarget:self action:@selector(saveArray) forControlEvents:UIControlEventTouchUpInside];

开发者_运维知识库How would this code be different if the method was in a different class?

[saveButton addTarget:self action:@selector(saveArray) forControlEvents:UIControlEventTouchUpInside];


Pass the object (which responds to the method) as the target parameter.

[saveButton addTarget:targetObj action:@selector(saveArray) forControlEvents:UIControlEventTouchUpInside];


You'd have to replace self with an instance of the other class.

0

精彩评论

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