問題描述
我不想將此應用提交到 AppStore.我已經嘗試了很多次,但遇到了很多問題:(
I don't want to submit this app to AppStore. I've tried for many times but met so many problems :(
我使用 class-dump 來獲取 UIKit.framework 的所有頭文件.在class-dump生成的UIApplication.h中,看到了我要使用的方法----launchApplicationWithIdentifier.
I use class-dump to get all the header files of UIKit.framework. In the UIApplication.h generated by class-dump, I saw the method I want to use----launchApplicationWithIdentifier.
然后我將 UIApplication.h 放入我的項目中并導入它.編譯,我得到了很多重新定義枚舉器......"錯誤,因為在我之前使用的 UIKit.framework 中,還有另一個 UIApplication.h.但是這個文件沒有launchApplicationWithIdentifier方法.
Then I put UIApplication.h in my project and import it. Compile, I got a lot of "Redefinition of enumerator...." error because in the UIKit.framework I use previous, there's another UIApplication.h. But this file doesn't have the method launchApplicationWithIdentifier.
如果我刪除之前的 UIKit.framework 并導入 class-dump 生成的文件夾.然后它看起來像一個框架,但如果我展開它,它是空的.
If I delete the previous UIKit.framework and import the folder generated by class-dump. Then it appears like a framework but if I unfold it, it's empty.
然后我想讓所有生成的頭文件成為一個框架文件,替換之前的UIKit.framework.但我不知道怎么做.我們可以看到,在系統框架目錄下,有一個與框架同名的文件,并且有一個已執行的shell腳本"圖標.我怎樣才能制作這個文件?
Then I want to make all generated header files a framework file ant replace the previous UIKit.framework. But I don't know how. As we can see, under the system framework directory, there's a file which has the same name as the framework and has a 'executed shell script' icon. How can I made this file?
我真的很困惑.有人可以幫我一把嗎?謝謝.
I really got confused. Someone can give me a hand? Thank you.
推薦答案
只要在你想使用的類實現上面的類別接口中指定私有方法,像這樣:
Just specify the private methods in a category interface above the class implementation where you want to use it, like this:
@interface UIApplication (Private)
- (BOOL)launchApplicationWithIdentifier:(id)identifier suspended:(BOOL)suspended;
@end
不要導入整個類轉儲文件并與原始 UIKit 框架鏈接.
Don't import the whole class-dump file and link with the original UIKit framework.
使用私有 API 時必須非常小心.這些方法可以在未來的 iOS 版本中更改或刪除!
You must be very careful when using private API. These methods can change or be removed in future iOS versions!
在運行時用 respondsToSelector:
檢查方法是否真的存在,并為它不存在的情況做好準備.
Check if the method really exists with respondsToSelector:
at runtime and be prepared for the case that it does not exist.
我在自己的應用程序中使用了一個秘密的 MapKit 功能,并且我知道私有方法僅存在于 iOS 5 中.所以我的應用程序仍然適用于所有 iOS 版本,但此功能僅在 iOS 5 中可用(Apple 刪除或更改了它在 iOS 6 beta 1) 中.
I used a secret MapKit feature in my own application and I knew that the private methods only exist in iOS 5. So my app still works in all iOS versions but this feature is only available in iOS 5 (Apple removed or changed it in iOS 6 beta 1).
這篇關于iOS 如何使用私有 API?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!