iOS 9 Undeclared选择器

时间:2015-10-17 17:24:25

标签: ios uiimagepickercontroller performselector

为什么更新到iOS 9后这行代码不起作用?

警告是未声明的选择器' performThisMethod:_ImageData

应用程序在[self performSelector:]

上崩溃
[self performSelector:@selector(performThisMethod:_ImageData:)withObject:nil afterDelay:0.05f];

-(void) performThisMethod : (NSData *) data {
     NSLog(@"Testing this Method");

  }

Apple改变了什么?

2 个答案:

答案 0 :(得分:1)

您错误地使用了performSelector。你想要:

[self performSelector:@selector(performThisMethod:) withObject:_ImageData afterDelay:0.05f];

更好的是,使用dispatch_after

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.05 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
    [self performThisMethod:_ImageData];
});

答案 1 :(得分:0)

您的代码应该是

[self performSelector:@selector(performThisMethod:) withObject:_ImageData afterDelay:0.05f];

请查看json_decode()以更好地了解performSelector行为。