【问题标题】:Xcode 4.2 error: receiver type for instance message does not declare a method with selectorXcode 4.2 错误:例如消息的接收器类型未声明带有选择器的方法
【发布时间】:2012-02-23 22:25:30
【问题描述】:

ARC 错误:“接收器类型 'FirstViewController' 例如消息未声明带有选择器 'updateWithEvent' 的方法”

我知道这是因为 ARC,在 xcode 4.2 中,但是任何人都可以帮助解决这个问题:

- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region      {
    NSString *event = [NSString stringWithFormat:@"didEnterRegion %@ at %@",     region.identifier, [NSDate date]];

    [self updateWithEvent:event];
}


- (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region {
    NSString *event = [NSString stringWithFormat:@"didExitRegion %@ at %@",     region.identifier, [NSDate date]];

    [self updateWithEvent:event];
}


- (void)locationManager:(CLLocationManager *)manager monitoringDidFailForRegion:(CLRegion *)region withError:(NSError *)error {
    NSString *event = [NSString stringWithFormat:@"monitoringDidFailForRegion %@: %@", region.identifier, error];

    [self updateWithEvent:event];
}

错误发生在每个 [self updateWithEvent:event];行。

任何帮助都会很棒,谢谢

【问题讨论】:

  • 这种情况下的错误告诉你,这里的 self 不管它可能是什么都没有实现 updateWithEvent。在这种情况下 self 是什么,它应该实现 updateWithEvent 吗?
  • 我认为这与 ARC 无关。正如其他人所说,您只是在某处缺少方法声明。

标签: ios xcode4.2 automatic-ref-counting


【解决方案1】:
  1. 检查 FirstViewController 中是否有方法 updateWithEvent
  2. 将其放在 LocationManager 委托方法之前或在头文件中定义此方法。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-07
    • 1970-01-01
    相关资源
    最近更新 更多