iOS 呼叫私有API

2021-07-09 20:21:15 字數 1493 閱讀 5972

objecitve-c的重要特性是runtime(執行時),在interacting with the runtime(互動執行)中,執行時函式部分,蘋果給出了/usr/lib/libobjc.a.dylib庫,這個共享庫提供支援動態屬性的objective - c語言,通過其介面,可以用於開發將其他語言執行於objective-c上的中間層(橋接層),庫里的函式定義為純c語言。

例如:class_getname

[cpp]view plain

copy

print?

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 

ifcls is nil.  

declared in  

runtime.h  

這裡我們要用庫里的函式,幹個「壞事」,檢視蘋果sdk的私有方法。

第一步:匯入標頭檔案

[cpp]view plain

copy

print?

#import 

第二步:新增下列**

[cpp]view plain

copy

print?

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(

inti = 0; i

sel a = method_getname(*(m+i));  

nsstring *sn = nsstringfromselector(a);  

nslog(@"%@"

,sn);  

}   

第三步:想看什麼類 就把uiview換成你想要的

當然,如果只是檢視私有api,會有更簡單的方法,可以使用工具class-dump,也可以通過此鏈結,    檢視。

iOS私有Api檢測

但是我使出了渾身解數,也沒找到自己寫的 裡 用到了私有api,最後網上找了一些檢測私有api的方法才發現在sdk裡面涉及到了 下面就檢測私有api的方法簡單介紹一下 首先要cd到工程目錄 cd 到工程的目錄 複製 全域性搜尋的命令 注意後面有乙個點 其中prefs即為你要搜尋的私有api grep ...

iOS私有Api檢測

在網上找了一些檢測私有api的方法才發現在sdk裡面涉及到了 下面就檢測私有api的方法簡單介紹一下 這是最顯而易見的,也是最方便解決的可能出現私有api的情況 當然這種方法首先你要知道使用了那些私有api,然後在 中進行全域性搜尋,修改,此方法暫不贅述 這些方法,我在查詢的時候基本能定位到使用私有...

iOS開發獲取SDK下私有API

objecitve c的重要特性是runtime 執行時 在interacting with the runtime 互動執行 中,執行時函式部分,蘋果給出了 usr lib libobjc.a.dylib庫,這個共享庫提供支援動態屬性的objective c語言,通過其介面,可以用於開發將其他語言...