AppleScript NSArray

[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



|

[reverseObjectEnumerator]逆順に並び替え

#!/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
property refNSString : a reference to refMe's NSString
property refNSURL : a reference to refMe's NSURL
property refNSMutableArray : a reference to refMe's NSMutableArray

set objFileManager to refMe's NSFileManager's defaultManager()

##############################
####フォルダ選択
##############################

set aliasDefaultLocation to (path to desktop folder from user domain) as alias
set strPromptText to "フォルダを選んでください" as text

try
set aliasDirPath to (choose folder strPromptText with prompt strPromptText default location aliasDefaultLocation without multiple selections allowed, invisibles and showing package contents)
on error
log "エラーしました"
return
end try
#####フォルダのパス
set strDirPath to POSIX path of aliasDirPath
#####String
set ocidDirPath to refNSString's stringWithString:strDirPath
#####NSURL
set ocidDirPathURL to refNSURL's fileURLWithPath:ocidDirPath
######フォルダの中にあるファイル一覧
set listFilesListArray to objFileManager's contentsOfDirectoryAtURL:ocidDirPathURL includingPropertiesForKeys:(missing value) options:(refMe's NSDirectoryEnumerationSkipsHiddenFiles) |error|:(reference)
set ocidFilesListArray to item 1 of listFilesListArray

####################
#####並び替え後のリスト用
set ocidSortArray to refNSMutableArray's alloc()'s initWithCapacity:0
###繰り返し
repeat with objArrayItem in ocidFilesListArray
####テキスト形式のパスに戻して
set strArrayItemPath to (objArrayItem's |path|()) as text
####順番に格納していく
(ocidSortArray's insertObject:strArrayItemPath atIndex:0)
end repeat


log "■■■■■■■正順リスト"
log (ocidSortArray's sortedArrayUsingSelector:"localizedCaseInsensitiveCompare:") as list

####逆順に並び替え
set ocidSortedArray to (ocidSortArray's sortedArrayUsingSelector:"localizedCaseInsensitiveCompare:")'s reverseObjectEnumerator()'s allObjects()

log "■■■■■■■逆順リスト"
log ocidSortedArray as list

|

[Sort]並び替えの違い compare と localizedStandardCompare

localizedStandardCompare


#!/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

property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSArray : a reference to objMe's NSArray
set objFileManager to objMe's NSFileManager's defaultManager()

###################
###設定項目
###中央部オフセット
set numCenterOffset to 0 as integer
###サイド部オフセット
set numSideOffset to 470 as integer

###################
###フォルダ選択

tell application "Finder"
set aliasDefaultLocation to (path to desktop folder from user domain) as alias
end tell
try
set aliasFolderResponse to (choose folder "画像が入っているフォルダを選んでください" with prompt "フォルダを選択してください" default location aliasDefaultLocation without multiple selections allowed, invisibles and showing package contents)
on error
log "エラーしました"
return
end try

###フォルダのパス
set strDirPath to POSIX path of aliasFolderResponse as text

###NSStringテキスト
set objDirPath to objNSString's stringWithString:strDirPath

###ディレクトリのコンテンツ一覧
set arrayFilesList to objFileManager's contentsOfDirectoryAtPath:objDirPath |error|:(missing value)
log className() of arrayFilesList as text

###並び替え
set ocidSelf to objNSString's stringWithString:"self"
set ocidDescriptor to objMe's NSSortDescriptor's sortDescriptorWithKey:ocidSelf ascending:true selector:"localizedStandardCompare:"
set ocidSortedList to (arrayFilesList's sortedArrayUsingDescriptors:{ocidDescriptor}) as list
####リストにしておく
set lisFileNames to ocidSortedList as list
log lisFileNames as list
-->
(*__NSArrayM*)
(*.DS_Store, 1.jpg, 2.jpg, 3.jpg, 4.jpg, 5.jpg, 6.jpg, 7.jpg, 8.jpg, 9.jpg, 10.jpg, 11.jpg, 12.jpg, 13.jpg, 14.jpg, 15.jpg, 16.jpg, 17.jpg, 18.jpg, 19.jpg, 20.jpg, 21.jpg, 22.jpg, 23.jpg, 24.jpg, 25.jpg, 26.jpg, 27.jpg, 28.jpg, 29.jpg, 30.jpg, 31.jpg, 32.jpg, 33.jpg, 34.jpg, 35.jpg, 36.jpg, 37.jpg, 38.jpg, 39.jpg, 40.jpg, 41.jpg, 42.jpg, 43.jpg, 44.jpg, 45.jpg, 46.jpg, 47.jpg, 48.jpg, 49.jpg, 50.jpg, 51.jpg, 52.jpg, 53.jpg, 54.jpg, 55.jpg, 56.jpg, 57.jpg, 58.jpg, 59.jpg, 60.jpg, 61.jpg, 62.jpg, 63.jpg, 64.jpg, 65.jpg, 66.jpg, 67.jpg, 68.jpg, 69.jpg, 70.jpg, 71.jpg, 72.jpg, 73.jpg, 74.jpg, 75.jpg, 76.jpg, 77.jpg, 78.jpg, 79.jpg, 80.jpg, 81.jpg, 82.jpg, 83.jpg*)

compare
#!/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

property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSArray : a reference to objMe's NSArray
set objFileManager to objMe's NSFileManager's defaultManager()

###################
###設定項目
###中央部オフセット
set numCenterOffset to 0 as integer
###サイド部オフセット
set numSideOffset to 470 as integer

###################
###フォルダ選択

tell application "Finder"
set aliasDefaultLocation to (path to desktop folder from user domain) as alias
end tell
try
set aliasFolderResponse to (choose folder "画像が入っているフォルダを選んでください" with prompt "フォルダを選択してください" default location aliasDefaultLocation without multiple selections allowed, invisibles and showing package contents)
on error
log "エラーしました"
return
end try

###フォルダのパス
set strDirPath to POSIX path of aliasFolderResponse as text

###NSStringテキスト
set objDirPath to objNSString's stringWithString:strDirPath

###ディレクトリのコンテンツ一覧
set arrayFilesList to objFileManager's contentsOfDirectoryAtPath:objDirPath |error|:(missing value)
log className() of arrayFilesList as text

###並び替え
set ocidSelf to objNSString's stringWithString:"self"
set ocidDescriptor to objMe's NSSortDescriptor's sortDescriptorWithKey:ocidSelf ascending:true selector:"compare:"
set ocidSortedList to (arrayFilesList's sortedArrayUsingDescriptors:{ocidDescriptor}) as list
####リストにしておく
set lisFileNames to ocidSortedList as list
log lisFileNames as list
-->

(*__NSArrayM*)
(*.DS_Store, 1.jpg, 10.jpg, 11.jpg, 12.jpg, 13.jpg, 14.jpg, 15.jpg, 16.jpg, 17.jpg, 18.jpg, 19.jpg, 2.jpg, 20.jpg, 21.jpg, 22.jpg, 23.jpg, 24.jpg, 25.jpg, 26.jpg, 27.jpg, 28.jpg, 29.jpg, 3.jpg, 30.jpg, 31.jpg, 32.jpg, 33.jpg, 34.jpg, 35.jpg, 36.jpg, 37.jpg, 38.jpg, 39.jpg, 4.jpg, 40.jpg, 41.jpg, 42.jpg, 43.jpg, 44.jpg, 45.jpg, 46.jpg, 47.jpg, 48.jpg, 49.jpg, 5.jpg, 50.jpg, 51.jpg, 52.jpg, 53.jpg, 54.jpg, 55.jpg, 56.jpg, 57.jpg, 58.jpg, 59.jpg, 6.jpg, 60.jpg, 61.jpg, 62.jpg, 63.jpg, 64.jpg, 65.jpg, 66.jpg, 67.jpg, 68.jpg, 69.jpg, 7.jpg, 70.jpg, 71.jpg, 72.jpg, 73.jpg, 74.jpg, 75.jpg, 76.jpg, 77.jpg, 78.jpg, 79.jpg, 8.jpg, 80.jpg, 81.jpg, 82.jpg, 83.jpg, 9.jpg*)

|

[NSIndex]NSMutableIndexSet [NSArray] objectsAtIndexes

可変NSIndex=NSMutableIndex


#!/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 objNSArray : a reference to objMe's NSArray


set listSampleB to {"a", "b", "c", "d", "e"} as list

####NSArrayI ここでこのリストをもとにArray
set ocidNSFrozenArrayM to objNSArray's alloc()'s initWithArray:listSampleB
log className() of ocidNSFrozenArrayM as text
log ocidNSFrozenArrayM as list

#### NSMutableIndex 初期化
set ocidNSIndexSet to objMe's NSMutableIndexSet's alloc()'s init()

### 0と1を追加する 0スタート
ocidNSIndexSet's addIndex:1
ocidNSIndexSet's addIndex:0

###↑INDEXで指定したArrayオブジェクトを取得する
set ocidNewArray to ocidNSFrozenArrayM's objectsAtIndexes:ocidNSIndexSet


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



#########################ログ表示
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
end if
end repeat

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

|

[NSArray] init

#!/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 objNSArray : a reference to objMe's NSArray


set listSampleB to {"a", "b", "c", "d", "e"} as list

####NSArrayI ここでこのリストをもとにArrayにするが
set ocidNSFrozenArrayM to objNSArray's alloc()'s initWithArray:listSampleB
log className() of ocidNSFrozenArrayM as text
log ocidNSFrozenArrayM as list

####NSArray0 で作ったArrayを初期化 空のリストにする
set ocidNSFrozenArrayM to objNSArray's alloc()'s init()
log className() of ocidNSFrozenArrayM as text
log ocidNSFrozenArrayM as list



#########################ログ表示
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
end if
end repeat

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

|

[List]フォルダ内のリスト

フォルダの第一階層
list folder で取得すると『ソートされていない』
取得→ソート が必須



#!/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 objNSArray : a reference to objMe's NSArray

###アプリケーションサポートフォルダ
tell application "Finder"
set aliasListFolder to path to application support folder from user domain as alias
end tell

### バックアップフォルダの中身
###ここで『フォルダの中身』を取得しています
tell application "Finder"
set listInSideFolder to (list folder aliasListFolder without invisibles) as list
end tell
-->この段階では、名前順にソートされていない

##### NSArray
set ocidNsArrayList to objNSArray's arrayWithArray:listInSideFolder

##### ソートキー
set theDescriptor to objMe's NSSortDescriptor's sortDescriptorWithKey:"self" ascending:true selector:"localizedStandardCompare:"

##### ソート処理 --> ocidSortedListにはソート済み ABC順のリストarrayに入っています
set ocidSortedList to (ocidNsArrayList's sortedArrayUsingDescriptors:{theDescriptor})

##### 
log ocidSortedList as list

|

[NSArray]要素色々

#!/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 objNSArray : a reference to objMe's NSArray
property objNSMutableArray : a reference to objMe's NSMutableArray

#####100リスト

set listTextString to {"mV5PRP-VROs", "gl4_N6vbyMo", "E4MtQKoR45k", "s9fO-G1xcJY", "89ueESHlmEk", "D-l1nfVC1Ro", "O0mohTml1YI", "up27LBOnpjA", "ysY_PHmSBr0", "WQ4TRwpgW98", "-kVgu1UPdrE", "CmhNAHtCQi8", "S_fQRxGGsAs", "u0hlcCWsy40", "yYTGqjhCle8", "H8R3wjvcq24", "dw21mTHfse4", "k_XQHfxEY6g", "yXOTK8VIqEk", "vjgXPM_UfsI", "QeVHV93pneQ", "iCASlg9kxls", "zEgkaAbz0Qk", "XHZF1rLnPWc", "B4bGopBetHs", "6cGCGUFypKU", "EkEOUa0sPtA", "QdAhdv94MFk", "s9DTDD9h3jY", "5R_DXjQk6do", "QKfp81XVzTc", "ImmWDYibbmI", "q0Xjonp_ojs", "vCmVV-kC_9E", "6YahzhX4gjg", "lvG57pyqwnk", "2OZK30AzSEw", "KHfAXUpw65U", "NY1kO3BU2Xc", "tmDVmAe0x1U", "MeI47znxpEY", "GIxFUUHSVYE", "xrjOMAcTQQU", "CpLJwVgXKsY", "V63h2CZ7L2Y", "iyf-xA9X_YM", "y4kbtfD7nhg", "EUZEvVe5QMs", "n-XGN5b89K0", "eUKM6JcI5SM", "VildgVhJ54Y", "ZVGicWO5G5g", "1oVhhIjHgOA", "RFzHVwLb9rw", "Q7YiNcJ7zPM", "yAkXqk2yi8w", "ireQAONfUSo", "f9cBxHARdEg", "4w_JIlSJS4U", "Z36Bb9WkHUA", "7GsEDCp5wYk", "q6xy7SNfAvE", "6CZzRspA5oY", "-nbPil9uvWQ", "USb2Stw0ark", "0aqLIR17Ank", "o2vWLxpOmtg", "QTHkqkh0G7k", "ickV3L9oVZQ", "IAMrcnevtKA", "wHoL7QZwFwE", "EB0veF0ZlXU", "mDRTUGSef-U", "cO0LTA_2Mus", "DNvyy-zYOLg", "DgAtedpvPBM", "S_n1QYgnFvM", "ISocTQ74LyQ", "RUb4RdnR1e8", "PQxbOswU47U", "yUngdmSu_Mo", "qRINAO-pJHM", "eWQY4Cp8sBs", "k4yXqDpwLYM", "O2u73OQHczY", "AlCCsNaYFik", "4d5nZ9QdQa8", "-qG97hzNryI", "JiCLLP1S0SU", "zWQ4318K4vQ", "6aaB-SIEWqc", "ZPRhq3fZfMo", "QwTyiDbKvOE", "pWRkzCGE9ds", "TTUDEhM_w2Q", "4-J7J9Q3m2w", "f94DfyS7pFE", "RmOX8uFx804", "eKOBGbNHmI0", "XkuFyyhqBJM"}



#####NSArray
set ocidNsArrayList to objNSArray's arrayWithArray:listTextString

#### NSArrayの数
set ocidNumCntList to ocidNsArrayList count
log ocidNumCntList as number
-->(*100*)

### 最初の値
##objectAtIndex
set ocidArrayOfIndex to ocidNsArrayList's objectAtIndex:0
log ocidArrayOfIndex as text
-->(*mV5PRP-VROs*)

##firstObject
set ocidFirstObject to ocidNsArrayList's firstObject()
log ocidFirstObject as text
-->(*mV5PRP-VROs*)

####最後の値
##objectAtIndex
set ocidArrayOfIndex to ocidNsArrayList's objectAtIndex:(ocidNumCntList - 1)
log ocidArrayOfIndex as text
-->(*XkuFyyhqBJM*)

##lastObject
set ocidLastObject to ocidNsArrayList's lastObject()
log ocidLastObject as text
-->(*XkuFyyhqBJM*)

### X個目の値
##objectAtIndex
set ocidArrayOfIndex to ocidNsArrayList's objectAtIndex:58
log ocidArrayOfIndex as text
-->(* 4w_JIlSJS4U*)

#### 範囲していした値
set ocidArrayOfIndex to ocidNsArrayList's subarrayWithRange:{0, 3}
log ocidArrayOfIndex as list
-->(*mV5PRP-VROs, gl4_N6vbyMo, E4MtQKoR45k*)

####値が含まれているか
set boolContain to ocidNsArrayList's containsObject:"mV5PRP-VROs"
log boolContain
-->(*true*)

set boolContain to ocidNsArrayList's containsObject:"DDDDD"
log boolContain
-->(*false*)

####何番目?にあるか?
set ocidIndex to ocidNsArrayList's indexOfObject:"4w_JIlSJS4U"
log ocidIndex as number
-->(*58*)

####要素の追加
###可変あれーに変換
set ocidNSMutableArray to ocidNsArrayList's mutableCopy()
ocidNSMutableArray's insertObject:"XXXXXX" atIndex:0
##確認
set ocidFirstObject to ocidNSMutableArray's firstObject()
log ocidFirstObject as text
-->(*XXXXXX*)

####要素の削除
###最初の要素削除
ocidNSMutableArray's removeObjectAtIndex:0
###確認
set ocidArrayOfIndex to ocidNSMutableArray's objectAtIndex:0
log ocidArrayOfIndex as text
-->(*mV5PRP-VROs*)

|

[sortDescriptorWithKey]並び替え(その2)

#!/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


property objMe : a reference to current application
property objNSArray : a reference to objMe's NSArray

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
end if
end repeat

set listTextString to {"東京", "神奈川", "千葉", "埼玉", "茨城", "群馬"}

set ocidNsArrayList to objNSArray's arrayWithArray:listTextString
set theDescriptor to objMe's NSSortDescriptor's sortDescriptorWithKey:"self" ascending:true selector:"compare:"
set ocidSortedList to (ocidNsArrayList's sortedArrayUsingDescriptors:{theDescriptor}) as list
log ocidSortedList
--> (*千葉, 埼玉, 東京, 神奈川, 群馬, 茨城*)
set ocidNsArrayList to objNSArray's arrayWithArray:listTextString
set theDescriptor to objMe's NSSortDescriptor's sortDescriptorWithKey:"self" ascending:true selector:"caseInsensitiveCompare:"
set ocidSortedList to (ocidNsArrayList's sortedArrayUsingDescriptors:{theDescriptor}) as list
log ocidSortedList
--> (*千葉, 埼玉, 東京, 神奈川, 群馬, 茨城*)
set ocidNsArrayList to objNSArray's arrayWithArray:listTextString
set theDescriptor to objMe's NSSortDescriptor's sortDescriptorWithKey:"self" ascending:true selector:"localizedCompare:"
set ocidSortedList to (ocidNsArrayList's sortedArrayUsingDescriptors:{theDescriptor}) as list
log ocidSortedList
--> (*茨城, 群馬, 埼玉, 神奈川, 千葉, 東京*)

set ocidNsArrayList to objNSArray's arrayWithArray:listTextString
set theDescriptor to objMe's NSSortDescriptor's sortDescriptorWithKey:"self" ascending:true selector:"localizedCaseInsensitiveCompare:"
set ocidSortedList to (ocidNsArrayList's sortedArrayUsingDescriptors:{theDescriptor}) as list
log ocidSortedList
--> (*茨城, 群馬, 埼玉, 神奈川, 千葉, 東京*)

set ocidNsArrayList to objNSArray's arrayWithArray:listTextString
set theDescriptor to objMe's NSSortDescriptor's sortDescriptorWithKey:"self" ascending:true selector:"localizedStandardCompare:"
set ocidSortedList to (ocidNsArrayList's sortedArrayUsingDescriptors:{theDescriptor}) as list
log ocidSortedList
--> (*茨城, 群馬, 埼玉, 神奈川, 千葉, 東京*)

|

[NSArray]リストの値を取得する(逆順)

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use framework "Foundation"
use AppleScript version "2.4"
use scripting additions
property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSMutableArray : a reference to objMe's NSMutableArray


set strText to "AAAA BBBB CCCCC DDDD" as text
####NSString
set ocidText to objNSString's stringWithString:strText
####区切り文字(componentsSeparatedByString)でリスト化
set ocidTextNSArray to ocidText's componentsSeparatedByString:" "
-->(*AAAA, BBBB, CCCCC, DDDD*)
log ocidTextNSArray as list
###リストの値の数を数える
set numCntArray to ocidTextNSArray count
-->4
set numRepeatCnt to 0
###正順
repeat numCntArray times
log (ocidTextNSArray's objectAtIndex:numRepeatCnt) as text
set numRepeatCnt to numRepeatCnt + 1
end repeat
###正順
repeat with objText in ocidTextNSArray
log objText as text
end repeat

######逆順
repeat with numCntRepeat from 1 to (numCntArray)
log (ocidTextNSArray's objectAtIndex:(numCntArray - numCntRepeat)) as text
end repeat

######
repeat
set numCntArray to numCntArray - 1
try
log (ocidTextNSArray's objectAtIndex:numCntArray) as text
on error
exit repeat
end try
end repeat

|

[count]リストの値の数(count of NSArray)

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use framework "Foundation"
use AppleScript version "2.4"
use scripting additions
property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSMutableArray : a reference to objMe's NSMutableArray


set strText to "AAAA BBBB CCCCC DDDD" as text
####NSString
set ocidText to objNSString's stringWithString:strText
####区切り文字(componentsSeparatedByString)でリスト化
set ocidTextNSArray to ocidText's componentsSeparatedByString:" "
-->(*AAAA, BBBB, CCCCC, DDDD*)
log ocidTextNSArray as list
###リストの値の数を数える
set numCntArray to ocidTextNSArray count
-->4

|

その他のカテゴリー

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