1 Star 0 Fork 0

人间不知德/uidevice-extension

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
UIDevice-Capabilities.m 1.66 KB
一键复制 编辑 原始数据 按行查看 历史
/*
Erica Sadun, http://ericasadun.com
iPhone Developer's Cookbook, 3.0 Edition
BSD License, Use at your own risk
*/
#import "UIDevice-Capabilities.h"
#import <dlfcn.h>
/*
THIS CATEGORY IS NOT APP STORE SAFE AT THIS TIME. DO NOT USE IN PRODUCTION CODE.
YOU CAN, HOWEVER, USE THIS TO HELP BUILD YOUR OWN CUSTOM CODE TO PRE_COMPUTE CAPABILITIES.
*/
#define GRAPHICS_SERVICES_PATH "/System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices"
@implementation UIDevice (Capabilities)
- (BOOL) supportsCapability: (NSString *) capability
{
void *libHandle = dlopen(GRAPHICS_SERVICES_PATH, RTLD_LAZY);
int (*GSSystemHasCapability)(NSString *);
GSSystemHasCapability = dlsym(libHandle, "GSSystemHasCapability");
BOOL result = GSSystemHasCapability(capability);
dlclose(libHandle);
return result;
}
- (id) fetchCapability: (NSString *) capability
{
void *libHandle = dlopen(GRAPHICS_SERVICES_PATH, RTLD_LAZY);
int (*GSSystemCopyCapability)(NSString *);
GSSystemCopyCapability = dlsym(libHandle, "GSSystemCopyCapability");
id capabilityValue = (id) GSSystemCopyCapability(capability);
dlclose(libHandle);
return [capabilityValue autorelease];
}
- (void) scanCapabilities
{
printf("Device: %s\n", [[self fetchCapability: UIDeviceMarketingNameString] UTF8String]);
for (NSString *capability in CAPABILITY_STRINGS)
{
printf("%s: %s\n", [capability UTF8String], [self supportsCapability:capability] ? "Yes" : "No");
}
}
- (NSArray *) capabilityArray
{
NSMutableArray *array = [NSMutableArray array];
for (NSString *capability in CAPABILITY_STRINGS)
{
if ([self supportsCapability:capability])
[array addObject:capability];
}
return array;
}
@end
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/worldunknowme/uidevice-extension.git
git@gitee.com:worldunknowme/uidevice-extension.git
worldunknowme
uidevice-extension
uidevice-extension
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385