ios - 应用程序因无法识别的选择器发送到实例而崩溃 - 可能是骗局

标签 ios objective-c

我知道有人问过这个问题,但我看到的答案都没有帮助我。如果您认为我遗漏了一个可能有用的信息,请告诉我。我看到其他示例,其中 View Controller 根本没有试图设置的变量,但我的情况不是这样。

我在 segue 期间遇到此错误:

-[EditPropertyViewController setLawnNumber:]: unrecognized selector sent to instance 0x19a301e0

每当我在 prepareForSegue 中点击这个 if block 时:

if( [segue.identifier isEqual:@"editProperty"])
{
    EditPropertyViewController *destView = segue.destinationViewController;
    destView.lawnNumber = _lawnNumber;
    destView.latitude = _latitude;
    destView.longitude = _longitude;
    destView.address = _serviceAddressLabel.text;

}

我的 .m 文件顶部确实有#import "EditPropertyViewController.h"。我确实有一个带有标识符“editProperty”的 segue,它推送一个设置为类型 EditPropertyViewController 的 View 控件。

这里是 EditPropertyViewController.h,表明我有我要设置的变量:

#import <UIKit/UIKit.h>
#import <GoogleMaps/GoogleMaps.h>

@interface EditPropertyViewController : UIViewController
@property (nonatomic, strong) GMSMapView *mapView;
@property (nonatomic, strong) GMSCameraPosition *camera;
@property(strong, nonatomic) NSString *address;
@property (nonatomic) CLLocationDegrees latitude;
@property (nonatomic) CLLocationDegrees longitude;
@property (nonatomic) int lawnNumber;

@end

我对相同的变量类型使用相同的方法,并且在其他 segues 期间不传递数据,但我没有看到我在这里做了什么不同的事情来导致这个问题。我还没有在其他任何地方创建 [customVC setVariable:] 方法,也没有遇到这个问题。

感谢任何建议!

编辑 - 按照@David H 的建议,我在尝试设置值之前添加了这两行:

NSLog(@"Actual class is %@", NSStringFromClass([destView class]));

assert( [destView class] == NSStringFromClass([destView class]));

导致以下输出:

    2015-02-27 16:56:27.623 LawnGuru[2730:460942] Actual class is EditPropertyViewController 
Assertion failed: ([destView class] == NSStringFromClass([destView class]))

从 Storyboard 中复制/粘贴,这是我试图转至的 VC 类型:“EditPropertyViewController”,这是我正在访问的 .h 文件:#import“EditPropertyViewController.h”

最佳答案

有时,从我在其他问题中看到的情况来看,Xcode 似乎出现了问题,解决该问题的唯一方法是删除涉嫌违规的代码并重新添加它。尝试删除 lawnNumber 属性,然后重新执行。

关于ios - 应用程序因无法识别的选择器发送到实例而崩溃 - 可能是骗局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28774798/

相关文章:

使用 Poco 库的 C++/IOS Websockets

ios - 分析此崩溃报告

objective-c - CALayer 和 View 消失了

objective-c - 在缓冲区中添加2个正弦波会产生噪声

ios - 如何在 UILabel 中显示不同的颜色和字体类型

ios - Interface Builder - 限制最大宽度和边距

ios - @Published 属性包装器不适用于 ObservableObject 的子类

ios - 如何 'pop' 导航 Controller 及其所有 View Controller

ios - 定期更新UITextField

iphone - 从 float 或 double 实例化 NSDecimalNumber 的正确方法