What do %new and %class mean in terms of MobileSubstrate tweaks? For instance:
%class TPBottomLockBar;
and
%new(v@:)
Sorry for double question!
These are both Logos constructs. %new
is for adding new methods to a class at runtime, and its syntax is %new(typeencoding)
; you can get information on Objective-C type encodings in Apple's Objective-C runtime documentation. Note that the first two arguments to these methods are always id and SEL, so the second two characters of your type encoding have to be "@:
". The first character is the return type, and anything else is your set of custom arguments.
As an example, here is a pretty un-useful method:
%hook NSMutableString
%new(v@:)
- (void)appendAwesomeThings {
[self appendString:@"Awesome."];
}
%end
(this will actually probably not work as NSString is a class cluster, but it serves as an example no less!)
%class
is a deprecated directive for forward-declaring a class to be used at runtime; It's been replaced with %c(ClassName)
, which is to be used inline.
For example,
[[%c(NSString) alloc] initWithString:@"Cool."];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With