robertwijas / UISS

UIAppearance Stylesheets
MIT License
1.23k stars 80 forks source link

Crash on iOS5 -[__NSArrayM objectAtIndexedSubscript:]: unrecognized selector sent to instance #25

Closed vkodocha closed 11 years ago

vkodocha commented 11 years ago

Looks like the lib has an issue with the array subscript syntax used inside the NSArray+UISS category code. When you use this on iOS 5 it will crash with the following exception: -[__NSArrayM objectAtIndexedSubscript:]: unrecognized selector sent to instance

From my research it look like that the back warts support for array subscription does not work from within a category.

I'm not sure if this lib is still supporting / or should be still supporting iOS 5 but from the pod file found in the example I expect that it does at the moment. So it would perhaps make sense to fix the code.

@implementation NSArray (UISS)

- (BOOL)canConvertToIntObjectAtIndex:(NSUInteger)index {
    return self.count > index && [[self objectAtIndex:index] respondsToSelector:@selector(intValue)];
}

- (BOOL)canConvertToFloatObjectAtIndex:(NSUInteger)index {
    return self.count > index && [[self objectAtIndex:index] respondsToSelector:@selector(floatValue)];
}

@end
robertwijas commented 11 years ago

Which SDK are you compiling your code with?

vkodocha commented 11 years ago

Hi I'm compiling with the 6.1 SDK, and the deployment target set to iOS 5.1.

When I was looking into this issue I found one comment on StackOverflow about how Apple creates the backwards support of the new syntax for iOS 5 by creating a special category on the NSArray class. I'm assuming that this is was causing the issue.

robertwijas commented 11 years ago

I cannot reproduce this crash. AFAIK if you compile with SDK >= 6.0 everything should work just fine.