Objecitve-C的重要特性是Runtime(運行時),在Interacting with the Runtime(交互運行)中,運行時函數部分,蘋果給出了/usr/lib/libobjc.A.dylib庫,這個共享庫提供支持動態屬性的objective - c語言,經過其接口,能夠用於開發將其餘語言運行於Objective-C上的中間層(橋接層),庫裏的函數定義爲純C語言。git
例如:class_getNamegithub
- class_getName
- Returns the name of a class.
-
- const char * class_getName(Class cls)
- Parameters
- cls
- A class object.
- Return Value
- The name of the class, or the empty string if cls is Nil.
-
- Declared In
- runtime.h
這裏咱們要用庫裏的函數,幹個「壞事」,查看蘋果SDK的私有方法。app
第一步:導入頭文件iphone
第二步:添加下列代碼函數
**************實用************工具
- NSString *className = NSStringFromClass([UIView class]);
-
-
- const char *cClassName = [className UTF8String];
-
- id theClass = objc_getClass(cClassName);
-
- unsigned int outCount;
-
-
- Method *m = class_copyMethodList(theClass,&outCount);
-
- NSLog(@"%d",outCount);
- for (int i = 0; i<outCount; i++) {
- SEL a = method_getName(*(m+i));
- NSString *sn = NSStringFromSelector(a);
- NSLog(@"%@",sn);
- }
第三步:想看什麼類 就把UIView換成你想要的oop
固然,若是隻是查看私有API,會有更簡單的方法,能夠使用工具class-dump,也能夠經過此連接,https://github.com/kennytm/iphone-private-frameworks/tree/master/UIKit/ 查看。spa
特別注意的是,若是是須要上架的APP,切勿使用私有API,會通不過APP Store的審覈。.net