At the very start of my app (applicationDidFinishLaunching) I test if a critical file is available, using a method called
attempToLoadRegister
If the file is available, I load it. If no, I offer the choice to create a new empty one (using NSSavePanel) or find an existing --maybe moved-- , file using NSOpenPanel.
Of course, I first tell the user that the file was not found, using a sheet alert with three buttons (Quit, Create or Search). So far so good. The “Search” button launches an NSOpenPanel (a standard one, not a sheet). On return, the new path is stored into the preferences (using [NSURL path]). So far so good.
But the alert sheet is NOT dismissed. It stays on the main window, the colored ball begins to spin and I’m forced to quit.
Why is this alert not dismissed? I use a unique “disSheetEnd” handler for all my alerts, relying on a “selector” to know which alert condition launched the sheet. For other alerts, everything is fine, but this one causes problems.
This is the method:
if (returnCode == NSAlertDefaultReturn) {[self lookForExistingRegister]; } call this:
}
So what? I thought it was a infinite loop, but where? the second time attempToLoadRegister is called, the path is set so no alert will occur.
I’m lost into my own code. Sob.
EDIT: I put a log into attempToLoadRegister. It is not called the second time. Where on earth is my execution pointer? Not in the main loop, certainly.
I’m using often literal strings as contextInfo parameter and check them with the normal equation expression ( == ).
Works flawlessly in MacOS and iOS.
Maybe because a literal string constant (NSConstantString) is treated slightly different than an NSString object
I didn’t touch anything, not even relaunched Xcode, and suddenly everything works as planned.
This is worse than having found a bug and correcting it. WHY did Xcode (or my app) freeze? Is it an inner bug? Where? Will it come again? Now I feeling unsecure. And what is this “ToolbarArrangeByTemplate” error?
I could say to myself “Well, everything is cool now, it works, so let start something else”.
This message suddenly disappeared and my code works as it should have from the beginning: sheets are removed and the code flow executed normally.
I don’t understand. Maybe another application interferes ? I noticed than sometimes, when debugging with Xcode, I get a message from Photoshop, running in background, saying “The request cannot be completed because of a program error”. It is possible that multiple threads somewhat interact?
The message has definitely something to do with NSOpenPanel/NSSavePanel/NSPanel. When one of these dialogs are opened (not as sheet), this message is sent to the output log:
Could not find image named ‘ToolbarArrangeByTemplate’