【问题标题】:IOS5 -[__NSCFDictionary nombre]: unrecognized selector sent to instance 0x6da25a0IOS5-[__NSCFDictionary nombre]:无法识别的选择器发送到实例 0x6da25a0
【发布时间】:2012-02-15 20:22:42
【问题描述】:

尝试访问“事件”类的属性时出现错误

Json List all Ok 当我尝试访问错误跳转时

Evento* bean = [ListaEventos objectAtIndex:indexPath.row];    
DetalleViewController *detalle = [self.storyboard    instantiateViewControllerWithIdentifier:@"Detalle"];
NSLog(@"detalle: %@",[bean nombre]);//bean Log OK!!, but bean.nombre Error!! why?

类:evento.h

@interface Evento : NSObject

@property (strong, nonatomic)  NSString *idevento;
@property (strong, nonatomic)  NSString *nombre;
@property (strong, nonatomic)  NSString *descripcion;
@property (strong, nonatomic)  NSString *fecha;
@property (strong, nonatomic)  NSString *telefono;
@property (strong, nonatomic)  NSString *direccion;

@end

Evento.m

@implementation Evento

@synthesize idevento;
@synthesize nombre;
@synthesize descripcion;
@synthesize fecha;
@synthesize telefono;
@synthesize direccion;

@end

【问题讨论】:

  • 显然,bean 是一个NSDictionary,而不是Evento 的一个实例。最有可能的是,您需要启用 NSZombies 并寻找过度发布。

标签: iphone objective-c ios5 instance


【解决方案1】:

你从[ListaEventos objectAtIndex:indexPath.row]; 得到的东西是善意的NSDictionary,而不是善意的Evento。检查您的数据!

【讨论】:

  • 顺便检查一下objective-c变量命名约定。
  • 谢谢,这是一个菜鸟的错误,而不是保存对象保留了字典不适当的命名 = 错误...感谢和抱歉这个愚蠢的问题 xD
  • 不客气,我们都去过!如果您的问题现在已解决,请通过接受适当的答案来结束问题。
【解决方案2】:

你得到的对象

[ListaEventos objectAtIndex:indexPath.row];

是没有方法或属性名词的字典类型。 如果您可以添加也可以在此处添加 json,我们可以帮助您获取正确的 eventto 对象。

【讨论】:

    猜你喜欢
    • 2013-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-28
    • 2012-07-24
    相关资源
    最近更新 更多