There is nothing in your code per se that I can see to cause the
second "if-end if" block to be accessed.
If I were to debug it, I would do this:
1. take out - temporarily - the "try" and "end try" lines.
At the moment if something is causing an error, you're not to know it
- the code will just jump to "end will open".
2. put a "log theObject" line in as the first line after "on will open
theObject"
Run and check the log to see that the handler is being called at all.
Note that with Xcode 3 you bring up the log window by selecting
"Console" from the "Run" menu.
If nothing appears in the log when it should (meaning that the handler
isn't being called), then you need to:
a. check your connection in Interface Builder. One thing I have
noticed with the new Interface Builder is that when you click
somewhere in an open window the Inspector palette shows the content
view of the window, not the window. Check the title in the Inspector
Palette. It should say "Window ..." not "View ...". If you're seeing
"View ...", to get the window you need to click again on the title bar
of your window.
b. If the connection is all OK, then the problem might well be
occurring BEFORE the "on will open" handler should be called. If there
is an "on awake from nib" handler, I'd be looking for an error in
there. I'd also check the code for opening the window (the code that
should cause the "on will open" handler to be triggered).
If the log says something like "... window id ...", then the handler
is being called, so ...
3. put a "log objectname" on a line after "set objectname to name of
theObject as Unicode text"
Run and check the log, you should see "genPrefs". If you do, then I
can't see any reason why the "if objectname is "genPrefs" then" block
shouldn't be accessed ... but my guess is that you won't see
"genPrefs" and there is something problematic happening earlier on.
Apologies if the above is all a case of "stating the obvious"!
Philip
On 11 May 2008, at 23:35, Romy Opena wrote:
Hi All,
After switching to Xcode 3.0, I suddenly had problem with my
application that worked with the old version of Xcode.
In my "will open" handler, I have these code snippets:
on will open theObject
try
set objectname to name of theObject as Unicode text
--no problem reading codes in window "main"
if objectname is"main"then
tell window"main"
--codes inside this tell block are read perfectly; no problem
end tell
end if
if objectname is "genPrefs" then
--display dialog "I am inside this if block (this line is not even
read at all)
tell window "genPrefs"
--it follows that the codes inside this tell block aren't read either
end tell
end if
end try
end will open
Is there any particular reason why the codes in second "if-end if"
block above can't be accessed? Note: The object "genPrefs" is a
preference window that contains tab view and tab view items but the
most immediate problem obviously is reading the first line (display
dialog) in the block. I put that line simply for test.