gpt4 book ai didi

iphone - [__NSCFNumber 长度] : unrecognized selector sent to instance

转载 作者:行者123 更新时间:2023-12-01 17:20:47 29 4
gpt4 key购买 nike

我正在尝试将数据从 TableView Controller 传递到详细 View Controller 。我的表中的每个条目都可以正常工作,除了一个。
这是 prepareForSegue 方法:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([[segue identifier] isEqualToString:@"showDetails"]) {
NSIndexPath *indexPath = [[self tableView] indexPathForSelectedRow];
NSDictionary *notification = [[self notifications] objectAtIndex:[indexPath row]];
NRDetailViewController *destViewController = [segue destinationViewController];
[destViewController setDate:[notification objectForKey:@"date"]];
[destViewController setFrom:[notification objectForKey:@"from"]];
[destViewController setIden:[notification objectForKey:@"identifier"]];
[destViewController setPriority:[notification objectForKey:@"priority"]];
[destViewController setSubject:[notification objectForKey:@"subject"]];
[destViewController setMessage:[notification objectForKey:@"text"]];

}
}

这是我的详细 View 界面:
#import <UIKit/UIKit.h>

@interface NRDetailViewController : UIViewController

@property (weak, nonatomic) IBOutlet UITextField *dateField;
@property (weak, nonatomic) IBOutlet UITextField *fromField;
@property (weak, nonatomic) IBOutlet UITextField *idenField;

@property (weak, nonatomic) IBOutlet UITextField *prioField;
@property (weak, nonatomic) IBOutlet UITextField *subjectField;
@property (weak, nonatomic) IBOutlet UITextView *messageView;


@property (copy, nonatomic) NSString *date;
@property (copy, nonatomic) NSString *from;
@property (copy, nonatomic) NSString *iden;
@property (copy, nonatomic) NSString *priority;
@property (copy, nonatomic) NSString *subject;
@property (copy, nonatomic) NSString *message;


@end

这是详细 View 的实现文件:
#import "NRDetailViewController.h"

@interface NRDetailViewController ()

@end

@implementation NRDetailViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}

- (void)viewDidLoad
{
[super viewDidLoad];
[[self dateField] setText:[self date]];
[[self fromField] setText:[self from]];
[[self idenField] setText:[self iden]];
[[self prioField] setText:[self priority]];
[[self subjectField] setText:[self subject]];
[[self messageView] setText:[self message]];



}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

@end

我在将 idenField 的文本设置为 iden 的文本时遇到问题。我添加了一个异常断点,并且发现异常确实发生在这一行:
[[self idenField] setText:[self iden]];

此时,我已经打印了 [self iden] 的值,它甚至包含了我想要传递的内容,所以我完全不知道问题出在哪里,因为正如我所说,所有其他字段都在正常工作.

抛出的异常是:
2013-08-07 22:28:20.539 NotificationReader[1214:11303] -[__NSCFNumber length]: unrecognized selector sent to instance 0x7587a00

任何帮助将不胜感激。

最佳答案

看起来像:

[destViewController setIden:[notification objectForKey:@"identifier"]];

正在返回 NSNumber 而不是 NSString。您可以尝试将该行替换为:
[destViewController setIden:[(NSNumber*)[notification objectForKey:@"identifier"] stringValue]];

关于iphone - [__NSCFNumber 长度] : unrecognized selector sent to instance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18113319/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com