NSMutableArray

[NSSet]Arrayの重複項目を除去


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

property refMe : a reference to current application

set strText to "美しい日本語1"

set ocidArrayM to refMe's NSMutableArray's alloc()'s initWithCapacity:0
ocidArrayM's addObject:strText

set listArray to {"美しい日本語1", "美しい日本語2", "美しい日本語3"} as list
ocidArrayM's addObjectsFromArray:listArray

log ocidArrayM as list
-->(*美しい日本語1, 美しい日本語1, 美しい日本語2, 美しい日本語3*)

##重複削除
set ocidTrimArray to ocidArrayM's valueForKeyPath:("@distinctUnionOfObjects.self")
log ocidTrimArray as list
-->(*美しい日本語2, 美しい日本語3, 美しい日本語1*)

##重複削除 NSset
set ocidArraySet to refMe's NSSet's setWithArray:(ocidArrayM)
set ocidTrimArray to ocidArraySet's allObjects()
log ocidTrimArray as list
-->(*美しい日本語2, 美しい日本語3, 美しい日本語1*)

##並び替え
set ocidSortedArray to ocidTrimArray's sortedArrayUsingSelector:("localizedCaseInsensitiveCompare:")
log ocidSortedArray as list
-->(*美しい日本語2, 美しい日本語3, 美しい日本語1*)

repeat with itemSortedArray in ocidSortedArray
  log itemSortedArray as text
end repeat


repeat with itemNo from 0 to (count of ocidSortedArray) - 1 by 1
  log (ocidSortedArray's objectAtIndex:(itemNo)) as text
end repeat



|

[sortedArrayUsingSelector]重複行を調べる

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7

use AppleScript version "2.8"
use framework "Foundation"
use scripting additions


property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSURL : a reference to objMe's NSURL
property objNSMutableString : a reference to objMe's NSMutableString
property objNSArray : a reference to objMe's NSArray
property objNSMutableArray : a reference to objMe's NSMutableArray
property objNSCharacterSet : a reference to objMe's NSCharacterSet



####ダイアログで使うデフォルトロケーション
tell application "Finder"
##set aliasDefaultLocation to container of (path to me) as alias
set aliasDefaultLocation to (path to desktop folder from user domain) as alias
end tell

####UTIリスト
set listUTI to {"public.plain-text"}

####ダイアログを出す
set aliasFilePath to (choose file with prompt "PDFファイルを選んでください" default location (aliasDefaultLocation) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias

set strFilePath to POSIX path of aliasFilePath
####ドキュメントのパスをNSString
set ocidFilePath to objNSString's stringWithString:strFilePath
####ドキュメントのパスをNSURL
set ocidFilePathURL to objNSURL's alloc()'s initFileURLWithPath:ocidFilePath

####################################
###読み込みデータの格納先の初期化
set ocidReadData to objNSMutableString's alloc()'s initWithCapacity:0
####データ読み込み
set ocidReadData to objNSMutableString's stringWithContentsOfURL:ocidFilePathURL encoding:(objMe's NSUTF8StringEncoding) |error|:(missing value)
#####並び替え用のリストの初期化
set ocidMutableArray to objNSMutableArray's alloc()'s initWithCapacity:0
#####改行を区切り文字に
set ocidNewlineCharacterSett to objNSCharacterSet's newlineCharacterSet()
#####テキストをリストに格納
set ocidMutableArray to ocidReadData's componentsSeparatedByCharactersInSet:ocidNewlineCharacterSett


####################################
###並び替え
set ocidSelf to objNSString's stringWithString:"self"
####並び替え実行
set ocidSortedArray to ocidMutableArray's sortedArrayUsingSelector:"localizedCaseInsensitiveCompare:"

log ocidSortedArray as list
log className() of ocidSortedArray as text


##################
####ソートされたリストを再格納
set ocidMutableArray to objNSMutableArray's alloc()'s initWithCapacity:0
ocidMutableArray's addObjectsFromArray:ocidSortedArray
####リストの数を数えて
set numCntArrayData to count of ocidMutableArray
####0スタートなので1つ引いた数を総数に
set numCntNo to (numCntArrayData - 1) as number
####リストの数だけ繰り返し
repeat numCntArrayData times
####A:カウント番号の内容(処理はリストの最後から前へ向かう)
set strItemA to (ocidMutableArray's objectAtIndex:(numCntNo as number)) as text
log strItemA
####B:カウント番号の1つ手前のリストの内容
set numCntBeforNo to numCntNo - 1 as number
set strItemB to (ocidMutableArray's objectAtIndex:(numCntBeforNo as number)) as text
log strItemB
#####ABが内容が同じなら=内容が重複していない場合
if strItemA is not strItemB then
####カウント番号の項目を削除する
ocidMutableArray's removeObjectAtIndex:numCntNo
end if
set numCntNo to numCntNo - 1 as number
#####最後の行は処理しない
if numCntNo = 0 then
exit repeat
end if
end repeat
#####重複内容のリスト
log ocidMutableArray as list
####################################
######出力先パス
set strOutFilePath to (strFilePath & ".out.txt") as text
set ocidOutFilePathURL to objNSURL's alloc()'s initFileURLWithPath:strOutFilePath
####出力用のテキストの初期化
set ocidOutPutStrings to objNSMutableString's alloc()'s initWithCapacity:0

#####リスト毎に改行を入れて
repeat with objMutableArray in ocidMutableArray
(ocidOutPutStrings's appendString:(objMutableArray as text))
log objMutableArray as text
(ocidOutPutStrings's appendString:("\n"))
end repeat

####出力
set boolWritetoUrlArray to ocidOutPutStrings's writeToURL:ocidOutFilePathURL atomically:true encoding:(objMe's NSUTF8StringEncoding) |error|:(reference)

|

[NSMutableArray]基本 セット編

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7

use AppleScript version "2.8"
use framework "Foundation"
use framework "PDFkit"
use scripting additions

property refMe : a reference to current application
property refNSArray : a reference to refMe's NSArray
property refNSMutableArray : a reference to refMe's NSMutableArray

###初期化
set ocidNewArrayM to refNSMutableArray's alloc()'s initWithCapacity:0
set ocidNewArrayM to refNSMutableArray's alloc()'s init()
log ocidNewArrayM as list
log className() of ocidNewArrayM as text
-->(*__NSArrayM*)

#####前から順に追加
ocidNewArrayM's insertObject:"5番目" atIndex:0
log ocidNewArrayM as list
(*5番目*)

#####前から順に追加insertObject
ocidNewArrayM's insertObject:"1番目" atIndex:0
log ocidNewArrayM as list
(*1番目, 5番目*)

#####後ろに追加addObject
ocidNewArrayM's addObject:"8番目"
log ocidNewArrayM as list
(*1番目, 5番目, 8番目*)


#####後ろにリストで追加addObjectsFromArray
set listAddArray to {"7番目", "9番目", "10番目"} as list
ocidNewArrayM's addObjectsFromArray:listAddArray
log ocidNewArrayM as list
(*1番目, 5番目, 8番目, 7番目, 9番目, 10番目*)

#####順番変更 8と7 indexで2と3を入れ替えるwithObjectAtIndex
ocidNewArrayM's exchangeObjectAtIndex:2 withObjectAtIndex:3
log ocidNewArrayM as list
(*1番目, 5番目, 7番目, 8番目, 9番目, 10番目*)

#####最初を1に2番目を3にatIndexes
set listAddArray to {"4番目", "6番目"} as list
set ocidNSIndex to refMe's NSMutableIndexSet's alloc()'s init()
ocidNSIndex's addIndex:1
ocidNSIndex's addIndex:3
log ocidNSIndex as list
ocidNewArrayM's insertObjects:listAddArray atIndexes:ocidNSIndex
log ocidNewArrayM as list
(*1番目, 4番目, 5番目, 6番目, 7番目, 8番目, 9番目, 10番目*)

#####置き換えatIndexedSubscript
set listAddArray to {"1番目", "2番目"} as list
ocidNewArrayM's setObject:listAddArray atIndexedSubscript:0
log ocidNewArrayM as list
(*1番目, 2番目, 4番目, 5番目, 6番目, 7番目, 8番目, 9番目, 10番目*)

##置き換えreplaceObjectsInRange
set listAddArray to {"1番目", "2番目", "3番目"} as list
set ocidNSRange to refMe's NSMakeRange(0, 1)
ocidNewArrayM's replaceObjectsInRange:ocidNSRange withObjectsFromArray:listAddArray
log ocidNewArrayM as list
(*1番目, 2番目, 3番目, 4番目, 5番目, 6番目, 7番目, 8番目, 9番目, 10番目*)


###解放
ocidNewArrayM's release()


|

[NSMutableArray] removeObjectsAtIndexes Rangeで指定した範囲の項目を削除

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

######ログ表示
doLogView()

property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSMutableString : a reference to objMe's NSMutableString

property objNSArray : a reference to objMe's NSArray
property objNSMutableArray : a reference to objMe's NSMutableArray


set ocidMutableArray to objNSMutableArray's alloc()'s initWithCapacity:0
log ocidMutableArray as list
log className() of ocidMutableArray as text

set listArray to {"D", "E", "F"} as list

ocidMutableArray's addObjectsFromArray:listArray
log ocidMutableArray as list
log className() of ocidMutableArray as text

set listSampleB to {"A", "B", "C"} as list

####NSArray
set ocidNSFrozenArrayM to objNSArray's alloc()'s initWithArray:listSampleB
log ocidNSFrozenArrayM as list
log className() of ocidNSFrozenArrayM as text



set ocidIndexSet to objMe's NSMutableIndexSet's alloc()'s init()
log ocidIndexSet
log className() of ocidIndexSet as text
ocidIndexSet's addIndex:0
ocidIndexSet's addIndex:1
ocidIndexSet's addIndex:2
log ocidIndexSet
log className() of ocidIndexSet as text

ocidMutableArray's insertObjects:ocidNSFrozenArrayM atIndexes:ocidIndexSet
log ocidMutableArray as list
log className() of ocidMutableArray as text


set ocidNsRange to objMe's NSMakeRange(3, 3)
log class of ocidNsRange
log ocidNsRange as record



ocidMutableArray's removeObjectsInRange:ocidNsRange
log ocidMutableArray as list
log className() of ocidMutableArray as text



#########################ログ表示
to doLogView()

tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
tell application "Script Editor"
tell application "System Events"
tell process "Script Editor"
tell window 1
tell splitter group 1
tell splitter group 1
tell group 1
tell checkbox "返された値"
set boolValue to value as boolean
end tell
if boolValue is false then
click checkbox "返された値"
end if
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end if
end repeat

end doLogView
#########################

|

[NSMutableArray] removeObjectsAtIndexes NSindexで指定した範囲の項目を削除

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

######ログ表示
doLogView()

property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSMutableString : a reference to objMe's NSMutableString

property objNSArray : a reference to objMe's NSArray
property objNSMutableArray : a reference to objMe's NSMutableArray


set ocidMutableArray to objNSMutableArray's alloc()'s initWithCapacity:0
log ocidMutableArray as list
log className() of ocidMutableArray as text

set listArray to {"D", "E", "F"} as list

ocidMutableArray's addObjectsFromArray:listArray
log ocidMutableArray as list
log className() of ocidMutableArray as text

set listSampleB to {"A", "B", "C"} as list

####NSArray
set ocidNSFrozenArrayM to objNSArray's alloc()'s initWithArray:listSampleB
log ocidNSFrozenArrayM as list
log className() of ocidNSFrozenArrayM as text



set ocidIndexSet to objMe's NSMutableIndexSet's alloc()'s init()
log ocidIndexSet
log className() of ocidIndexSet as text
ocidIndexSet's addIndex:0
ocidIndexSet's addIndex:1
ocidIndexSet's addIndex:2
log ocidIndexSet
log className() of ocidIndexSet as text

ocidMutableArray's insertObjects:ocidNSFrozenArrayM atIndexes:ocidIndexSet
log ocidMutableArray as list
log className() of ocidMutableArray as text


set ocidDelIndexSet to objMe's NSMutableIndexSet's alloc()'s init()
log ocidDelIndexSet
log className() of ocidDelIndexSet as text
ocidDelIndexSet's addIndex:3
ocidDelIndexSet's addIndex:4
ocidDelIndexSet's addIndex:5
log ocidDelIndexSet
log className() of ocidDelIndexSet as text

ocidMutableArray's removeObjectsAtIndexes:ocidDelIndexSet
log ocidMutableArray as list
log className() of ocidMutableArray as text



#########################ログ表示
to doLogView()

tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
tell application "Script Editor"
tell application "System Events"
tell process "Script Editor"
tell window 1
tell splitter group 1
tell splitter group 1
tell group 1
tell checkbox "返された値"
set boolValue to value as boolean
end tell
if boolValue is false then
click checkbox "返された値"
end if
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end if
end repeat

end doLogView
#########################

|

[NSMutableArray] removeObjectAtIndex ×番目を削除

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

######ログ表示
doLogView()

property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSMutableString : a reference to objMe's NSMutableString

property objNSArray : a reference to objMe's NSArray
property objNSMutableArray : a reference to objMe's NSMutableArray


set ocidMutableArray to objNSMutableArray's alloc()'s initWithCapacity:0
log ocidMutableArray as list
log className() of ocidMutableArray as text

set listArray to {"D", "E", "F"} as list

ocidMutableArray's addObjectsFromArray:listArray
log ocidMutableArray as list
log className() of ocidMutableArray as text

set listSampleB to {"A", "B", "C"} as list

####NSArray
set ocidNSFrozenArrayM to objNSArray's alloc()'s initWithArray:listSampleB
log ocidNSFrozenArrayM as list
log className() of ocidNSFrozenArrayM as text



set ocidIndexSet to objMe's NSMutableIndexSet's alloc()'s init()
log ocidIndexSet
log className() of ocidIndexSet as text
ocidIndexSet's addIndex:0
ocidIndexSet's addIndex:1
ocidIndexSet's addIndex:2
log ocidIndexSet
log className() of ocidIndexSet as text

ocidMutableArray's insertObjects:ocidNSFrozenArrayM atIndexes:ocidIndexSet
log ocidMutableArray as list
log className() of ocidMutableArray as text



ocidMutableArray's removeObjectAtIndex:5
log ocidMutableArray as list
log className() of ocidMutableArray as text





#########################ログ表示
to doLogView()

tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
tell application "Script Editor"
tell application "System Events"
tell process "Script Editor"
tell window 1
tell splitter group 1
tell splitter group 1
tell group 1
tell checkbox "返された値"
set boolValue to value as boolean
end tell
if boolValue is false then
click checkbox "返された値"
end if
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end if
end repeat

end doLogView
#########################

|

[NSMutableArray] insertObjects atIndexes NSIndexで指定したオブジェクトを挿入

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

######ログ表示
doLogView()

property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSMutableString : a reference to objMe's NSMutableString

property objNSArray : a reference to objMe's NSArray
property objNSMutableArray : a reference to objMe's NSMutableArray


set ocidMutableArray to objNSMutableArray's alloc()'s initWithCapacity:0
log ocidMutableArray as list
log className() of ocidMutableArray as text

set listArray to {"D", "E", "F"} as list

ocidMutableArray's addObjectsFromArray:listArray
log ocidMutableArray as list
log className() of ocidMutableArray as text

set listSampleB to {"A", "B", "C"} as list

####NSArray
set ocidNSFrozenArrayM to objNSArray's alloc()'s initWithArray:listSampleB
log ocidNSFrozenArrayM as list
log className() of ocidNSFrozenArrayM as text



set ocidIndexSet to objMe's NSMutableIndexSet's alloc()'s init()
log ocidIndexSet
log className() of ocidIndexSet as text
ocidIndexSet's addIndex:0
ocidIndexSet's addIndex:1
ocidIndexSet's addIndex:2
log ocidIndexSet
log className() of ocidIndexSet as text

ocidMutableArray's insertObjects:ocidNSFrozenArrayM atIndexes:ocidIndexSet
log ocidMutableArray as list
log className() of ocidMutableArray as text

#########################ログ表示
to doLogView()

tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
tell application "Script Editor"
tell application "System Events"
tell process "Script Editor"
tell window 1
tell splitter group 1
tell splitter group 1
tell group 1
tell checkbox "返された値"
set boolValue to value as boolean
end tell
if boolValue is false then
click checkbox "返された値"
end if
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end if
end repeat

end doLogView
#########################

|

[NSMutableArray] insertObject Array形式 リスト形式を指定の場所に追加

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

######ログ表示
doLogView()

property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSMutableString : a reference to objMe's NSMutableString

property objNSArray : a reference to objMe's NSArray
property objNSMutableArray : a reference to objMe's NSMutableArray


set ocidMutableArray to objNSMutableArray's alloc()'s initWithCapacity:0
log ocidMutableArray as list
log className() of ocidMutableArray as text

set listArray to {"D", "E", "F"} as list

ocidMutableArray's addObjectsFromArray:listArray
log ocidMutableArray as list
log className() of ocidMutableArray as text

set listSampleB to {"A", "B", "C"} as list

####NSArray
set ocidNSFrozenArrayM to objNSArray's alloc()'s initWithArray:listSampleB
log ocidNSFrozenArrayM as list
log className() of ocidNSFrozenArrayM as text


ocidMutableArray's insertObject:ocidNSFrozenArrayM atIndex:0
log ocidMutableArray as list
log className() of ocidMutableArray as text

#########################ログ表示
to doLogView()

tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
tell application "Script Editor"
tell application "System Events"
tell process "Script Editor"
tell window 1
tell splitter group 1
tell splitter group 1
tell group 1
tell checkbox "返された値"
set boolValue to value as boolean
end tell
if boolValue is false then
click checkbox "返された値"
end if
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end if
end repeat

end doLogView
#########################

|

[NSMutableArray] addObjectsFromArray Array形式 リスト形式を追加

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

######ログ表示
doLogView()

property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSMutableString : a reference to objMe's NSMutableString

property objNSArray : a reference to objMe's NSArray
property objNSMutableArray : a reference to objMe's NSMutableArray


set ocidMutableArray to objNSMutableArray's alloc()'s initWithCapacity:0
log ocidMutableArray as list
log className() of ocidMutableArray as text

set listArray to {"A", "B", "C"} as list

ocidMutableArray's addObjectsFromArray:listArray
log ocidMutableArray as list
log className() of ocidMutableArray as text

set listSampleB to {"D", "E", "F"} as list

####NSArray
set ocidNSFrozenArrayM to objNSArray's alloc()'s initWithArray:listSampleB
log ocidNSFrozenArrayM as list
log className() of ocidNSFrozenArrayM as text


ocidMutableArray's addObjectsFromArray:ocidNSFrozenArrayM
log ocidMutableArray as list
log className() of ocidMutableArray as text

#########################ログ表示
to doLogView()

tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
tell application "Script Editor"
tell application "System Events"
tell process "Script Editor"
tell window 1
tell splitter group 1
tell splitter group 1
tell group 1
tell checkbox "返された値"
set boolValue to value as boolean
end tell
if boolValue is false then
click checkbox "返された値"
end if
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end if
end repeat

end doLogView
#########################

|

[NSMutableArray] addObject リスト形式を追加

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

######ログ表示
doLogView()

property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSMutableString : a reference to objMe's NSMutableString

property objNSArray : a reference to objMe's NSArray
property objNSMutableArray : a reference to objMe's NSMutableArray


set ocidMutableArray to objNSMutableArray's alloc()'s initWithCapacity:0
log ocidMutableArray as list
log className() of ocidMutableArray as text

set listArray to {"A", "B", "C"} as list

ocidMutableArray's addObject:listArray
log ocidMutableArray as list
log className() of ocidMutableArray as text


#########################ログ表示
to doLogView()

tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
tell application "Script Editor"
tell application "System Events"
tell process "Script Editor"
tell window 1
tell splitter group 1
tell splitter group 1
tell group 1
tell checkbox "返された値"
set boolValue to value as boolean
end tell
if boolValue is false then
click checkbox "返された値"
end if
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end if
end repeat

end doLogView
#########################

|

より以前の記事一覧

その他のカテゴリー

Accessibility Acrobat Acrobat 2020 Acrobat AddOn Acrobat Annotation Acrobat ARMDC Acrobat AV2 Acrobat BookMark Acrobat Classic Acrobat DC Acrobat Dialog Acrobat Distiller Acrobat Form Acrobat JS Acrobat Manifest Acrobat Menu Acrobat Open Acrobat Plugin Acrobat Preferences Acrobat Preflight Acrobat python Acrobat Reader Acrobat SCA Acrobat SCA Updater Acrobat Sequ Acrobat Sign Acrobat Stamps Acrobat Watermark Acrobat Windows Acrobat Windows Reader Admin Admin Account Admin Apachectl Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Mobileconfig Admin Permission Admin Pkg Admin Power Management Admin Printer Admin SetUp Admin SMB Admin Support Admin System Information Admin Tools Admin Users Admin Volumes Adobe Adobe FDKO Adobe RemoteUpdateManager AppKit Apple AppleScript AppleScript do shell script AppleScript List AppleScript ObjC AppleScript Osax AppleScript PDF AppleScript Pictures AppleScript record AppleScript Script Editor AppleScript Script Menu AppleScript Shortcuts AppleScript Shortcuts Events AppleScript System Events AppleScript System Events Plist AppleScript Video Applications AppStore Archive Attributes Automator BackUp Barcode Barcode QR Barcode QR Decode Bash Basic Basic Path Bluetooth BOX Browser Calendar CD/DVD Choose Chrome CIImage CityCode CloudStorage Color com.apple.LaunchServices.OpenWith Console Contacts CotEditor CURL current application Date&Time delimiters Desktop Device Diff Disk Dock DropBox Droplet eMail Encode % Encode Decode Encode UTF8 Error EXIFData ffmpeg File Finder Firefox Folder FolderAction Fonts GIF github Guide HTML HTML Entity Icon Illustrator Image Events Image2PDF ImageOptim iPhone iWork Javascript Jedit Json Label Leading Zero List locationd LRC lsappinfo LSSharedFileList m3u8 Mail MakePDF Map Math Media Media AVAsset Media AVconvert Media AVFoundation Media AVURLAsset Media Movie Media Music Memo Messages Microsoft Microsoft Edge Microsoft Excel Mouse Music NetWork Notes NSArray NSArray Sort NSBezierPath NSBitmapImageRep NSBundle NSCFBoolean NSCharacterSet NSColor NSColorList NSData NSDecimalNumber NSDictionary NSError NSEvent NSFileAttributes NSFileManager NSFileManager enumeratorAtURL NSFont NSFontManager NSGraphicsContext NSImage NSIndex NSKeyedArchiver NSKeyedUnarchiver NSLocale NSMutableArray NSMutableDictionary NSMutableString NSNotFound NSNumber NSOpenPanel NSPasteboard NSpoint NSPredicate NSPrintOperation NSRange NSRect NSRegularExpression NSRunningApplication NSScreen NSSize NSString NSString stringByApplyingTransform NSStringCompareOptions NSTask NSTimeZone NSURL NSURL File NSURLBookmark NSURLComponents NSURLResourceKey NSURLSession NSUserDefaults NSUUID NSView NSWorkspace Numbers OAuth OneDrive PDF PDFAnnotation PDFAnnotationWidget PDFContext PDFDisplayBox PDFDocumentPermissions PDFImageRep PDFKit PDFnUP PDFOutline perl Photoshop PlistBuddy pluginkit postalcode PostScript prefPane Preview Python QuickLook QuickTime ReadMe Regular Expression Reminders ReName Repeat RTF Safari SaveFile ScreenCapture ScreenSaver SF Symbols character id SF Symbols Entity sips Skype Slack Sound Spotlight sqlite SRT StandardAdditions Swift System Settings TCC TemporaryItems Terminal Text Text CSV Text MD Text TSV TextEdit Tools Translate Trash Twitter Typography UI Unit Conversion UTType valueForKeyPath Video VisionKit Visual Studio Code Wacom webarchive webp Wifi Windows XML XML EPUB XML OPML XML Plist XML RSS XML savedSearch XML SVG XML TTML XML webloc XML XMP YouTube zoom