Search code examples
ios8uiactionsheetnsrangeexception

I am unable to show just simple UIActionSheet in my application in IOS8 on real device


When I run this in IOS 8 I get NSRangeException exception

UIActionSheet *uias = [[UIActionSheet alloc] initWithTitle:@"Test"
                                                      delegate:self
                                             cancelButtonTitle:@"Test"
                                        destructiveButtonTitle:@"Test"
                                             otherButtonTitles:@"Test", nil];

[uias showInView:self.view];

Exception from output:

2014-09-26 22:18:17.106 rcherzios[354:51170] * Terminating app due to uncaught exception 'NSRangeException', reason: '* -[__NSArrayM replaceObjectAtIndex:withObject:]: index 0 beyond bounds for empty array' * First throw call stack: (0x2b153f87 0x38bc6c77 0x2b071331 0x10b587 0x2b96109b 0x2b961211 0x2b965897 0x2b963141 0x2b963579 0x2b964391 0x2b964215 0x2b966e2d 0x2b9641ab 0x2b99e65b 0x2b99d067 0x2b99ca87 0x2b9643e7 0x2b964215 0x2b966e2d 0x2b9641ab 0x2b99bd01 0x2b966e2d 0x2b99bc79 0x2b953bed 0x2b953ceb 0x2b11a82d 0x2b119af1 0x2b11864b 0x2b065db1 0x2b0af6cb 0x2b966b7f 0x392a6e67 0x392a6ddb 0x392a4b84) libc++abi.dylib: terminating with uncaught exception of type NSException Signal: 6 (signal SIGABRT)

In IOS7 and even in simulator IOS 8 everything works, just on real device in IOS8 it crashes...

It looks like in my complex application on wich I wokr for 3 years also all UIAlertView are crashing with same exception, i tried to test new UIAlertController and have same exception. So my conclusion is that some configuration of my application is causing problem to UIAlertController what is actually what UIAlertView and UIActionSheet are using in ios 8.


Solution

  • OK, this was my fault but I don't understand why this caused so hard to tackle problem just under this special circumstances IOS8 and build running on device and ...

    So this code caused problem...

    @implementation NSMutableArray (Extension)
    
    - (void)setObject:(id)thing atIndexedSubscript:(NSInteger)index {
        [self replaceObjectAtIndex:index withObject:thing];
    }