4
根據MobileSubstrate調整,%new和%class是什麼意思?例如:%new&%class的用途是什麼?
%class TPBottomLockBar;
和
%new([email protected]:)
對不起,雙待!
根據MobileSubstrate調整,%new和%class是什麼意思?例如:%new&%class的用途是什麼?
%class TPBottomLockBar;
和
%new([email protected]:)
對不起,雙待!
這些都是邏輯結構。 %new
用於在運行時向類添加新方法,其語法爲%new(typeencoding)
;您可以獲取有關Objective-C類型編碼in Apple's Objective-C runtime documentation的信息。請注意,這些方法的前兩個參數始終是id和SEL,因此類型編碼的後兩個字符必須是「@:
」。第一個字符是返回類型,其他任何內容都是您的一組自定義參數。
作爲一個例子,這裏是一個非常聯合國有用的方法:
%hook NSMutableString
%new([email protected]:)
- (void)appendAwesomeThings {
[self appendString:@"Awesome."];
}
%end
(這實際上可能不是NSString的工作是一類集羣,但它作爲一個例子不能少!)
%class
是一個不推薦使用的指令,用於在運行時前向聲明一個類;它已被替換爲%c(ClassName)
,它將被內聯使用。 例如,
[[%c(NSString) alloc] initWithString:@"Cool."];
您是否在使用Theos?你爲什麼不檢查文件,或詢問IRC? – EmilioPelaez
希望這是有用的http://iphonedevwiki.net/index.php/Logos http://iphonedevwiki.net/index.php/Special:AllPages –