我正在寫一個應用程序,使用Objective-C-appscript(objc-appscript)與Mail進行對話。我想複製當前選擇的郵件並稍後對其執行一些處理 - 此時當前的選擇可能已經改變。將id轉回到AppScript中的引用對象objective-c
MLApplication *mail = [[MLApplication alloc] initWithBundleID: @"com.apple.mail"];
MLReference *ref = [mail selection];
id theSelection = [[ref getItem] copy];
// Do something here, which may change the contents of ref,
// but that's okay since I made a copy in theSelection
MLMoveCommand *cmd = [[theSelection move] to: [[mail mailboxes] byName:@"test"]];
// This command should move the selected messages to the mailbox but fails
// because theSelection
MLReference *ref2 = nil; // Need to turn theSelection into an MLReference *
MLMoveCommand *cmd = [[ref2 move] to: [[mail mailboxes] byName:@"test"]];
我需要把選項變回MLReference *。我相信這應該是一個簡單的操作,但我對appscript並不熟悉,需要一些指導。謝謝!
我不確定它需要成爲MLReference。相反,我認爲它需要是一個AppScript列表對象。你如何將一個NSArray對象變成一個AppScript列表對象? – Adam 2011-01-22 07:45:27