私有API简单使用


iOS的API分为四种:

Published API(公开的API)(或者Documented API

还有两类:私有APIPrivate API和未公开APIUnPublished API(或者Undocumented API)

私有API是指放在PrivateFrameworks框架中的API,未公开的API是指虽然放在Frameworks框架中,但是却没有在苹果的官方文档中有使用说明、代码介绍等记录的API

按苹果的说法,未公开的API是还不够成熟,可能还会变动的API,等完全成型了后会变成公开的API,但是目前不对其提供承诺,就是系统版本升级后可能会失效。而私有API是苹果明确不能使用的API。虽然两者有所区别,但是在具体使用方法上是类似的。


私有API会面临审核通不过然后不能上线,但是也有使用私有API通过审核的比如谷歌的“Google Voice”,所以具体审核的详情不得而知。




github地址  https://github.com/sunlight2728/iOS-Runtime-Headers


iOS-Runtime-Headers 包含了所有的私有API,可以简单查阅

iOS9可行的使用方法:

NSBundle *b = [NSBundle bundleWithPath:@"/System/Library/PrivateFrameworks/FTServices.framework"];
BOOL success = [b load];

Class FTDeviceSupport = NSClassFromString(@"FTDeviceSupport");
id si = [FTDeviceSupport valueForKey:@"sharedInstance"];

NSLog(@"-- %@", [si valueForKey:@"deviceColor"]);

获取用户所有的bundle id

    Class LSApplicationWorkspace_class = objc_getClass("LSApplicationWorkspace");

    NSObject* workspace = [LSApplicationWorkspace_class performSelector:@selector(defaultWorkspace)];

    NSArray *arr =[workspace performSelector:@selector(allInstalledApplications)];

另一种获取方法
  Class LSApplicationWorkspace_class = NSClassFromString(@"LSApplicationWorkspace");

    NSObject* workspace = [LSApplicationWorkspace_class performSelector:@selector(defaultWorkspace)];

    

    NSArray *arrAPP =[workspace performSelector:@selector(allApplications)];



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值