views:

111

answers:

1

Hi, everyone,

I want to compare 2 NSString *. I use the [[arr objectAtIndex: i]compare: @"compareString"] . However, it does not work in my program. What wrong of the problems?

+1  A: 

Possible problems:

  1. You have indexed off the end of the array causing a bounds exception
  2. The array is nil meaning the compare would always result in equality
  3. The object in the array does not respond to compare: causing an unrecognized selector exception
  4. The object in the array is not a string causing compare: to fail

If you tell me what actually happens, I'll tell you which of the four possibilities is the issue.

JeremyP