Archive for the 'NSHost' Category

2015/08/26 ASOCでHostの情報を取得する

CocoaのNSHost関連のメソッドなどを調べてみました。

AppleScript名:ASOCでHostの情報を取得する
– Created 2015-08-26 by Takaaki Naganoya
– 2015 Piyomaru Software
use AppleScript version “2.4″
use scripting additions
use framework “Foundation”

set aHost to current application’s NSHost’s currentHost()

aHost’s localizedName()
–>  (NSString) “MBPretina”

aHost’s |name|()
–>  (NSString) “mbpretina.local”

aHost’s address()
–>  (NSString) “xxxx::xxxx:xxxx:xxxx:xxxx%en0″

aHost’s addresses()
–>  (NSArray) {​​​​​”xxxx::xxxx:xxxx:xxxx:xxxx%en0″, ​​​​​”192.168.0.10″, ​​​​​”xxxx::xxxx:xxxx:xxxx:xxxx%awdl0″, ​​​​​”xxxx::xxxx:xxxx:xxxx:xxxx%utun0″, ​​​​​”xxxx:xxxx:xxx:xxxx:xxxx:xxxx:xxxx:xxxx”, ​​​​​”xxxx::xxxx:xxxx:xxxx:xxx%utun1″, ​​​​​”xxxx::xxxx:xxxx:xxxx:xxxx%utun2″, ​​​​​”::1″, ​​​​​”127.0.0.1″, ​​​​​”xxxx::1%lo0″​​​}

set bHost to current application’s NSHost’s hostWithName:“mba13.local”
–>  (NSHost) (null) (() ())

bHost’s address()
–>  (NSString) “192.168.0.23″

set cHost to current application’s NSHost’s hostWithAddress:“192.168.0.23″
cHost’s |name|()
–>  missing value –Why ???????

bHost’s isEqualToHost:cHost
–>  true –OK

★Click Here to Open This Script