Question

I get an error when trying to access an attribute of a class "event"

Json List all Ok When I trying to access the error jumps

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

The class: 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
Was it helpful?

Solution

What you get out of [ListaEventos objectAtIndex:indexPath.row]; is of kind NSDictionary and not of kind Evento as supposed. Check your data!

OTHER TIPS

The object you get with

[ListaEventos objectAtIndex:indexPath.row];

Is of type dictionary which doesn't have the method or the property nombre. If you could add also add here the json we can help you to get the correct evento object.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top