2012-09-02 35 views
3

我是全新的Xcode 4.4和AppleScriptObjC。我試圖在Sanderson和Rosenthal的書「Learn AppleScript」中擴展和試驗AppleScriptObjC的教程,並且遇到了一個問題。代碼:Xcode/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以獲取網點檢查器...即使應該有另一個文本字段,也沒有Outlet。

任何想法?

+0

不是線索;這對我來說工作得很好...... – geowar

+0

我遇到同樣的問題你有沒有找到解決方案? –

回答

0

我是AppleScript的新手,我遇到的一個常見問題是我首先在applicationWillFinishLaunching部分聲明瞭屬性。檢查一下。如果它仍然不起作用(你確實提到你在適當的地方添加了代碼),那麼嘗試在「屬性父」部分之前放置第二個文本字段的屬性聲明。可能的工作,我想......

嘗試張貼您的AppDelegate.applescript

好運的全部代碼!

0
  1. 確保您添加的屬性不是一個動作

如內。這將不起作用:

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

例如。這應該工作:

property anotherTextField : missing value 
    on buttonClick_(sender) 
     .... 
    end buttonClick 
  • PS。您所做的變量「anotherTextField」,但在行動,你使用「otherTextField」

    property ---> anotherTextField <--- : missing value 
    ... 
    set theText to textField's stringValue() & ---> otherTextField <---'s stringValue() 
    
  • 如果沒有這種幫助,我也許能更好地理解它,如果您發佈完整的代碼,那麼我也許能以幫助您更多:D