NSCF Array Out of Bounds?
I have a fairly simple application using Core Data, and a couple Array Controllers (in IB, no code files for them, other than the xcdatamodel file). When I run my application, I get the following error in the log (the app still runs, but no window appears until I go to File > New Document):
2011-02-08 18:45:10.434 MyApp[35178:a0f] *** -[NSCFArray objectAtIndex:]: index (0) beyond bounds (0
)
I have no references in my myDocument.h or .m files to an array. The error is not critical (the app still runs), but it disables some of my code to load the last used document or (if that doesn't exist) load a fresh document. The app simply loads up with no visible windows. I would greatly appreciate some help on this and will award the answer quickly :)
EDIT: Here is the applicationShouldOpenUntitledFile code:
- (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender
{
NSArray* urls = [[NSDocumentController sharedDocumentController] recentDocume开发者_Python百科ntURLs];
if ([urls count] > 0){
NSURL *lastURL= [urls objectAtIndex: 0];
[[NSDocumentController sharedDocumentController] openDocumentWithContentsOfURL:lastURL display:YES error:nil];
return NO;
}
return YES;
}
Sorry to post here, I don't have the right to comment everywhere for the moment.
@Zakman411: Justin is saying you should enable the "Stop on Objective-C Exceptions" item in the Run menu, then launch the debugger. gdb should show you where the exception is thrown exactly.
精彩评论