Today, I checked the logos of THEOS, and added a common sign "% new" to the hook class to add new functions. For example, we want to implement the delegate method of a class for springboard. The simplest thing is to let the springboard implement the alert proxy method so that the corresponding response can be made after clicking the button.
Step 1: Let springboard implement the delegate method.
# Import<Springboard/Springboard. h>
@ InterfaceSpringboard () <uialertviewdelegate>
@ End
Everyone knows this role.
The second step is to add the implementation of the alert proxy method to the springboard.
% Hook springboard
%New(V @: @ I)
-(Void) Alertview :( uialertview *) Av clickedbuttonatindex :( nsinteger) buttonindex
{
If(Av. Tag! =10010)
{
Nslog (@ "Av. Tag! = 10010");
Return;
}
BoolRes = [[uiapplication sharedapplication] canopenurl: [nsurl urlwithstring:@ Http://www.126.com"];
If(RES ){
Nslog (@ "Open myapptest ://");
[[Uiapplication sharedapplication] Openurl: [nsurl urlwithstring:@ Http://www.126.com"];
}
}
% End
Here we will focus on the usage of % new.
A reply from a foreign website
All objective-C methods take at least two arguments, one of Type 'id', the other of Type 'sel '. these arguments are 'implicit', in that they are not explicitly declared by the programmer. the first is named 'self '(the object processing the message) and the other is' _ cmd', the selector for the sent message.
@ = ID
: = Sel
V @: =-/+ (void) Method
V @: @ =-/+ (void) methodwithobjectid :( ID) OBJ
V represents the return type void @ representing an objc object: Representing sel;
I Represents the int type
For more information about the specific symbols, see objective-C runtime programming guide (objective-C runtime programming guide)
Http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtTypeEncodings.html
The complete image of the previous simple demo. The environment is iosopendev.
This demo is implemented. After the instance is started, a dialog box pops up. After you click thanks, the page will jump to the 126 mailbox homepage.