看个例子吧:
#!/bin/sh
cd ~
mkdir shell_tut
cd shell_tut
@implementation NSMutNSableDictionary(Swizzing) | |
+ (void)load { | |
Class dictCls = NSClassFromString(@"__NSDictionaryM"); | |
Method originalMethod = class_getInstanceMethod(dictCls, @selector(setObject:forKey:)); | |
Method swizzledMethod = class_getInstanceMethod(dictCls, @selector(na_setObject:forKey:)); | |
method_exchangeImplementations(originalMethod, swizzledMethod); | |
} |
//// 检测微信OpenURL时回传参数和回调逻辑 | |
@implementation UIApplication(MethodSwizzing) | |
static void MySetFrame(id self, SEL _cmd, NSURL* url); | |
static void (*SetFrameIMP)(id self, SEL _cmd, NSURL* url); | |
static void MySetFrame(id self, SEL _cmd, NSURL* url) { | |
// do custom work | |
NSLog(@" url : %@",url); |
char -[MicroMessengerAppDelegate handleOpenURL:bundleID:](void * self, void * _cmd, void * arg2, void * arg3) { | |
r7 = (sp - 0x4 - 0x4 - 0x4 - 0x4 - 0x4) + 0xc; | |
sp = sp - 0x4 - 0x4 - 0x4 - 0x4 - 0x4 - 0x4 - 0x4 - 0x4 - 0x64; | |
r11 = loc_e0b370(arg2, _cmd, arg2, arg3, stack[2048], stack[2049], stack[2050], stack[2051], stack[2052]); | |
stack[2067] = loc_e0b370(arg3); | |
r6 = 0x1e42556; | |
r10 = @selector(logWithLevel:module:errorCode:file:line:func:format:); | |
r0 = @class(iConsole); | |
r2 = @"url[%@]"; | |
r3 = 0x73b; |
1. func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool 在函数里添加 | |
redirectConsoleLog() | |
/// redirect Log. | |
func redirectConsoleLog() { | |
#if DEBUG | |
let documentDir: String = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] | |
print("documentPath : \(documentDir)") |
链接: http://pan.baidu.com/s/1eR1rz5C 密码: irbm | |
http://www.paintcodeapp.com/documentation 文档 |
// | |
// | |
#import "LPViewController.h" | |
@interface LPViewController () | |
{ | |
CALayer *sublayer2,*sublayer3; | |
} | |
@end |
Swift 语言指南 | |
=== | |
这份指南汇集了 Swift 语言主流学习资源,并以开发者的视角整理编排。 | |
GitHub:[ipader/SwiftGuide](https://github.com/ipader/SwiftGuide) | 网站:[http://dev.swiftguide.cn](http://dev.swiftguide.cn) | _欢迎开发者一起[维护](https://github.com/ipader/SwiftGuide/pulls),或[反馈/投稿](https://github.com/ipader/SwiftGuide/issues/new)_ | |
> 想了解关于该指南及 Swift 更多信息的同学,可以阅读短文《[致 Swift 开发者](https://github.com/ipader/SwiftGuide/blob/master/2014%20letter.md)》。 想快速找到优秀开源项目的开发者,可以访问我们额外整理的[《Swift 开源项目精选》](https://github.com/ipader/SwiftGuide/blob/master/Featured.md)。希望快速找到其中精选文章,可以访问[《Swift 文章精选》](https://github.com/ipader/SwiftGuide/blob/master/Featured-Articles.md)。 | |
<span style="color:lightgray;font-size:12px">[@SwiftLanguage](http://weibo.com/swiftlanguage) 更新于 2015-4-26,更新内容详见[《2015-4-26 收录周报》](https://github.com/ipader/SwiftGuide/blob/master/weekly/2015-04-26.md)</span> |
public extension CGFloat { | |
public func toRadians() -> CGFloat { | |
return (self * CGFloat(M_PI)) / 180.0 | |
} | |
public func toDegrees() -> CGFloat { | |
return self * 180.0 / CGFloat(M_PI) | |
} |
shshjjsj |