简体   繁体   English

NSInvalidArgumentException无法识别的选择器已发送到实例

[英]NSInvalidArgumentException unrecognized selector sent to instance

I am working on a twitter viewing application and having an issue with getting the data to pass from the cell to the detail view. 我正在开发一个Twitter查看应用程序,并且在使数据从单元格传递到详细信息视图时遇到问题。 Everytime I click the cell my program terminates with this error. 每次单击单元格时,程序都会因此错误而终止。

2015-09-04 12:18:34.298 twitterView2[10580:872508] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[TwitterPostInfo objectForKey:]: unrecognized selector sent to instance 0x7f9fb261f890'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010527fc65 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000104f18bb7 objc_exception_throw + 45
    2   CoreFoundation                      0x00000001052870ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x00000001051dd13c ___forwarding___ + 988
    4   CoreFoundation                      0x00000001051dccd8 

Easiest way to find the location of the problem is in xCode go to the breakpoint navigator (Command + 7). 查找问题位置的最简单方法是在xCode中转到断点导航器(Command + 7)。 Click the + at the bottom and select "Add Exception Breakpoint". 单击底部的+,然后选择“添加例外断点”。 Now when you run your program it will stop when the exception occurs and show you the stack trace instead of the "uncaught exception" 现在,当您运行程序时,它将在发生异常时停止,并向您显示堆栈跟踪,而不是“未捕获的异常”

It's hard to know for sure without seeing where you're assigning the tweetDetail property of this class, but it would appear that you're assigning an object of type TwitterPostInfo, not NSDictionary. 在不知道要在哪里分配此类的tweetDetail属性的情况下很难确定,但是似乎您正在分配的是TwitterPostInfo类型的对象,而不是NSDictionary类型的对象。 Check where you're setting this property and be sure it's the correct type. 检查您要在哪里设置此属性,并确保它是正确的类型。

Alternatively, if you are intending to pass a TwitterPostInfo object, you'll have to change the type of tweetDetail to match. 或者,如果您打算传递TwitterPostInfo对象,则必须更改tweetDetail的类型以使其匹配。 Of course, you'll have to update how you access its data (I am assuming it's a custom class. I could not find anything via Google). 当然,您必须更新如何访问其数据(我假设它是一个自定义类。我无法通过Google找到任何内容)。

EDIT: 编辑:

After seeing your prepareForSegue method, my guess is that you're intending to pass along a TwitterPostInfo object, not an NSDictionary. 在看到了prepareForSegue方法之后,我的猜测是您打算传递一个TwitterPostInfo对象,而不是NSDictionary。 If this is true, you'll want to change tweetDetail's type from NSDictionary to TwitterPostInfo. 如果是这样,则需要将tweetDetail的类型从NSDictionary更改为TwitterPostInfo。 Then, instead of using [self.tweetDetail objectForKey:@"text"] and [self.tweetDetail objectForKey:@"created_at"] , you'll want to use something equivalent to self.tweetDetail.text and self.tweetDetail.createdAt depending on how you structured your class. 然后, [self.tweetDetail objectForKey:@"text"]使用[self.tweetDetail objectForKey:@"text"][self.tweetDetail objectForKey:@"created_at"] ,而是要使用与self.tweetDetail.textself.tweetDetail.createdAt等效的东西关于您的课程结构。

Try this for TwitterDetailVC.h: 为TwitterDetailVC.h尝试以下操作:

#import <UIKit/UIKit.h>
#import "TwitterPostInfo.h"

@interface TwitterDetailVC : UIViewController

@property (strong, nonatomic) TwitterPostInfo *tweetDetail;

@end

and this for TwitterDetailVC.m's viewDidLoad method 这是TwitterDetailVC.m的viewDidLoad方法

- (void)viewDidLoad {
    [super viewDidLoad];

    self.tweetTextLabel.text = self.tweetDetail.tweetText;
    self.tweetTimeLabel.text = self.tweetDetail.timeDate;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 NSInvalidArgumentException:无法识别的选择器发送到实例 - NSInvalidArgumentException: unrecognized selector sent to instance 无法识别的选择器已发送到实例(&#39;NSInvalidArgumentException&#39;) - Unrecognized selector sent to instance ('NSInvalidArgumentException') NSInvalidArgumentException:“无法识别的选择器发送到实例” - NSInvalidArgumentException: “Unrecognized selector sent to instance” NSInvalidArgumentException || 无法识别的选择器已发送到实例 - NSInvalidArgumentException || Unrecognized selector sent to instance iOS NSInvalidArgumentException,无法识别的选择器发送到实例 - iOS NSInvalidArgumentException, unrecognized selector sent to instance 错误:&#39;NSInvalidArgumentException&#39;...发送到实例的无法识别的选择器 - Error: 'NSInvalidArgumentException' … unrecognized selector sent to instance NSInvalidArgumentException - [__ NSCFString unsignedLongLongValue]:发送到实例的无法识别的选择器 - NSInvalidArgumentException -[__NSCFString unsignedLongLongValue]: unrecognized selector sent to instance NSInvalidArgumentException-[NSNull长度]:无法识别的选择器已发送到实例 - NSInvalidArgumentException -[NSNull length]: unrecognized selector sent to instance NSInvalidArgumentException,原因无法识别的选择器发送到实例 - NSInvalidArgumentException, reason unrecognized selector sent to instance 另一个“ NSInvalidArgumentException:无法识别的选择器发送到实例”帖子 - Another “NSInvalidArgumentException: unrecognized selector sent to instance” post
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM