On Sunday, I was working on my open source UIDevice extensions for the upcoming revision of my iPhone Developer's Cookbook. The Objective-C category that I've been building for a few months extends the UIDevice class to produce more robust information. With this code, UIDevice can now report its MAC address, its IP address, and express whether it supports a built-in camera or microphone, among other features. Here's a quick overview of the current interface:
enum { UIDeviceSupportsGPS = 1 << 0, UIDeviceBuiltInSpeaker = 1 << 1, UIDeviceBuiltInCamera = 1 << 2, UIDeviceBuiltInMicrophone = 1 << 3, UIDeviceSupportsExternalMicrophone = 1 << 4, UIDeviceSupportsTelephony = 1 << 5, UIDeviceSupportsVibration = 1 << 6 }; @interface UIDevice (Hardware) - (NSString *) platform; - (int) platformType; - (int) platformCapabilities; - (NSString *) platformString; - (NSUInteger) cpuFrequency; - (NSUInteger) busFrequency; - (NSUInteger) pageSize; - (NSUInteger) totalMemory; - (NSUInteger) userMemory; - (NSUInteger) maxSocketBufferSize; - (NSString *) macaddress; - (NSString *) hostname; - (NSString *) localWiFiIPAddress; - (NSString *) localIPAddress; @end
A couple of things that are not reported are the device IMEI and serial numbers. These are both pieces of information that I know are available via IOKit, as I use that framework in my jailbreak deviceinfo program which is part of my Erica Utilities. The I/O Kit registry stores hierarchical information about the hardware installed on a device.
You can get a sense of the kind of information available through this registry by running the ioreg command-line utility on a Macintosh. These details will obviously vary between an OS X system and an iPhone but you can see how the registry stores a huge amount of system information that can be valuable to developers. Enter ioreg -w0 -l | more
at the terminal and be prepared for a major information dump.
After tweeting about wishing that IOKit were public, I was surprised to be reminded that in fact it is. iPhone developer Layton Duncan pointed out that the framework lived in the public arena, and not in Apple's protected PrivateFrameworks
directory. So off I went to try to put this knowledge to use.
In Xcode, I was surprised to see that Apple didn't include IOKit header files. When I tried to add#import <IOKit/IOKit.h>
, the file could not be found. So I manually put together a simple header file by hand, added IOKit to my frameworks and attempted to compile.
As you can see from the screenshot at the top of this post, I failed to do so. Xcode complained that the IOKit framework could not be found. Despite being filed as public, IOKit is apparently not meant to be used by the general public. As iPhone evangelist Matt Drance tweeted, "IOKit is not public on iPhone. Lack of headers and docs is rarely an oversight."
In the official docs, I found a quote that described IOKit as such: "Contains interfaces used by the device. Do not include this framework directly." So in the end, my desire to access that IOKit information was thwarted. For whatever reason, Apple has chosen to list it as a public framework but the reality is that it is not.
相关推荐
How to get a PhD。第五版
How to Get Ideas - Jack Foster.pdf
How to get current user of sharepoint 2013
Do you feel like you'... If you want to get a promotion, you'll need to be a patient team player while also being an ambitious self-promoter. It's a difficult balance to strike, but these tips can help.
How to Get IPC MJPEG Stream via HTTP Commands
一本经典的指导读博的好书,正在读博士的兄弟们可以看看,会有一定收获的。
intending to embark on a research degree it will introduce you to the system and, by increasing your understanding, help you to improve your choice of university, college, department and supervisor.
29 How to Get Your App Featured on the App Store 29 How to Get Your App Featured on the App Store
28 How to Get Press Coverage for Your App 28 How to Get Press Coverage for Your App
How to get SAP Best Practices
如何最大程度的利用EDA仿真软件进行系统和器件分析,观点透彻独到
how to get the android resource code under ubuntu 8.04.I get it in the internet.
How to get all the IP available in LAN using java
How to Get a Cross-Browser Reference to an HTML Object
Leadership How to Get IT Research You Can Use
How to Get Notifications from a .NET Web Service。
How to Get Your Course Completion Certificate 2021.pdf
「安全认证」How to Get Promoted:Developing Metrics to Show How Threat Intel Works - 恶意软件 数据安全 防火墙 身份管理 安全体系 安全漏洞
HOWTO-html<br>News-HOWTO-html<br>News-Leafsite-html<br>Oracle-HOWTO-html<br>Plug-and-Play-HOWTO-html<br>PPP-HOWTO-html<br>Printing-HOWTO-html<br>QT 3.3 中文白皮书.pdf Quota RCS-...