XCode / AppleScriptObjC新手

时间:2012-09-02 17:31:37

标签: xcode applescript applescript-objc

我是Xcode 4.4和AppleScriptObjC世界的新手。我正试图在Sanderson和Rosenthal的“学习AppleScript”一书中扩展并试验AppleScriptObjC的教程,我遇到了一个问题。代码:

property parent : class "NSObject"
property textField : missing value

on buttonClick_(sender)
    set theText to textField's stringValue()
    set dialogText to text returned of (display dialog "Here is the text your entered: " & return & theText default answer "")
    textfield's setStringValue_(dialogText)
end buttonClick

完美运行,我得到了预期的对话框,一切正常。但是,如果我试图搞砸它并添加这两行(当然在适当的地方):

property anotherTextField : missing value
...
set theText to textField's stringValue() & otherTextField's stringValue()

程序仍在运行 - 但是! - 如果我转到MainMenu.xib并按住Ctrl键单击AppDelegate以获取插座检查器...即使应该有另一个文本字段,也没有出口。

有什么想法吗?

2 个答案:

答案 0 :(得分:0)

我也是AppleScript的新手,我遇到的一个常见问题是我首先在applicationWillFinishLaunching部分中声明了属性。检查一下。如果它仍然不起作用(你确实提到你在适当的地方添加了代码),那么尝试在“属性父”部分之前放置第二个文本字段的属性声明。我猜可能会工作......

尝试发布AppDelegate.applescript的完整代码

祝你好运!

答案 1 :(得分:0)

  1. 确保您添加的媒体资源不属于某项操作
  2. 例如。这不起作用:

        on buttonClick_(sender)
            property anotherTextField : missing value
            ....
        end buttonClick
    

    例如。这应该有效:

        property anotherTextField : missing value
        on buttonClick_(sender)
            ....
        end buttonClick
    
    1. PS。你创建了变量“anotherTextField”,但在你使用“otherTextField”

      的动作中
      property ---> anotherTextField <--- : missing value
      ...
      set theText to textField's stringValue() & ---> otherTextField <---'s stringValue()
      
    2. 如果这些都没有帮助,我可能会更好地理解它,如果你发布完整的代码,那么我可以帮助你更多:D

相关问题