[__NSArrayI length]: unrecognized selector sent to instance when moving through views


This question already has an answer here:


Object for key kMotivo is NSArray in your code. You are assigning it to NSString property and afterward to UILabel text property. UILabel tries to call length on NSArray and crash with an exception.

Something like following will work:

NSArray *motives = [reasonsDictionary objectForKey:kMotivo];
if (motives != nil && motives.count > 0) {
  int random = arc4random_uniform(motives.count);
  _reasonsMotivo = motives[random];

Code above will take first available motive from array and will assign it to a _reasonsMotivo. It should be inserted instead of following code line:

_reasonsMotivo = [reasonsDictionary objectForKey:kMotivo];

instead of:

kMotivo: @[@"Por que sim",@"Por que demais",@"Por que muito",@"Por que foda",@"Por que top",@"Por que demasiado"]


kMotivo: [[NSArray alloc]initWithObjects:@"Chapter 1",@"Chapter 2",@"Chapter 3",@"Chapter 4",@"Chapter 5",nil]

Need Your Help

Tomcat 7 Escape sequence

tomcat7 struts-1

Tomcat 7 double // append in html:form action value instead of single / please help me how to ignore it

Custom many-to-many mapping with CodeFirst

entity-framework entity-framework-4.1 ef-code-first

Start using CodeFirst in my MVC projects and have some trouble.