Performselector - 参数 2 从整数生成指针而不进行强制转换
我有这样的代码:
[self performSelector:@selector(animationWithType:) withObject:PasscodeAnimationTypeConfirm afterDelay:0.2];
对于这个方法:
-(void)animationWithType:(PasscodeAnimationType)type;
将它放在它的位置:
[self performSelector:@selector(animationWithType:) withObject:[NSNumber numberWithInt:PasscodeAnimationTypeConfirm] afterDelay:0.2];
返回一个“1”的 NSLog,我的方法不会将其归类为与 PasscodeAnimationTypeConfirm 相同的值。我该如何解决这个问题?
I have this code:
[self performSelector:@selector(animationWithType:) withObject:PasscodeAnimationTypeConfirm afterDelay:0.2];
To this method:
-(void)animationWithType:(PasscodeAnimationType)type;
Putting this in it's place:
[self performSelector:@selector(animationWithType:) withObject:[NSNumber numberWithInt:PasscodeAnimationTypeConfirm] afterDelay:0.2];
returns an NSLog of "1", which my method doesn't class as the same value as PasscodeAnimationTypeConfirm. How can i fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,据我所知,你只能用对象作为参数,而不是类型(整数、字符等)来执行performSelector:blahBlah:withDelay:。
您可以创建另一个函数来帮助您,如下所示:
并使用您发布的代码中的这个函数:
Yeah, as far as I know, you can only do performSelector:blahBlah:withDelay: with objects as parameters, not types (ints, chars, etc.).
You can create another function to help you, like this:
And using this one from the code you posted:
@Emilio:你的performSelector调用不应该调用你的新方法吗?
这是我的一个例子,展示了这个概念的更详细的用法。
http://kerkermeister.net/ Objective-c-adapter-from-nsinteger-to-id-when-using-performselector-withobject/
适配器如下所示并执行更多检查:
@Emilio: Shouldn't your performSelector call invoke your new method?
Here is an example of mine showing a more detailed use of this concept.
http://kerkermeister.net/objective-c-adapter-from-nsinteger-to-id-when-using-performselector-withobject/
The adapter looks like this and performs some more checks: