0

Main.m

    int main(int argc, char *argv[])
{
    @autoreleasepool {
        return
        UIApplicationMain
        (argc,
         argv,
         nil,
         NSStringFromClass
         ([AppDelegate class]));
    }
}

The debugger says the error is in the "NSStringFromClass" line. I have no idea what this means or is, please help me! :/

Ramaraj T
  • 5,184
  • 4
  • 35
  • 68
  • The above code is not useful. Put a breakpoint and find exactly where the exception is thrown. Post the crash log. NSRangeException normally occurs when you access an element that is beyond the array limit. – Ramaraj T May 27 '13 at 05:27
  • 2013-05-27 00:30:45.182 ReadNow[53528:c07] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSCFString substringToIndex:]: Range or index out of bounds' *** First throw call stack: (0x1e4f012 0x1331e7e 0x1e4edeb 0xd66089 0x9541 0x3bc4 0x45ac4e 0x45d224 0x321952 0x3212dc 0x35f4 0x4db853f 0x4dca014 0x4dba7d5 0x1df5af5 0x1df4f44 0x1df4e1b 0x20877e3 0x2087668 0x275ffc 0x266d 0x2595) libc++abi.dylib: terminate called throwing an exception – Colton Anglin May 27 '13 at 05:31
  • are you making this app for ios 5 and ios6 both? is the ARC is enabled.? – mAc May 27 '13 at 06:21

4 Answers4

1

As already mentioned, the error is not in the code you have pasted. You can however easily find the code line that contains the error:
In the left column of XCode open the breakpoint navigator. Then click at the bottom left the plus sign. In the context menu that appears, select "Add Exception Breakpoint".
If you now run your code with breakpojnts enabled, the debugger will stop at the line where your error is encountered, and you can easily check e.g. your rnge variables.

Reinhard Männer
  • 14,022
  • 5
  • 54
  • 116
0

Generally NSRangeException occurs when you are using NSArray or NSMutableArray and you want a use a value which is out of range of the array. I don't think there is problem in the the line you mentioned

0

The doc is here

- (NSString *)substringToIndex:(NSUInteger)anIndex

here an anIndex value must lie within the bounds of the receiver, or be equal to the length of the receiver.

Ramaraj T
  • 5,184
  • 4
  • 35
  • 68
0

NSRangeException - that means you've overrun the bounds of an array. The code you have pasted doesn't have any error. When xcode gets any uncaught exception it shows the main.m file, however this doesnt mean that the error is in that file or line.

Check the controller file of the view on which you got this error. Probably you are trying to access an array out of its bounds. For eg. in tableView if you are using any NSArray or NSMutableArray to display content and you return numberOfRowsInSection: more than the total count of that Array then you will get this error.

Sam
  • 440
  • 6
  • 18