未记录的iPhone API - 发现和使用

时间:2009-08-26 18:51:37

标签: iphone objective-c api

有一些iPhone应用程序正在使用未记录的API做一些幕后花絮,效果很好。

  1. 我如何获取未记录的iPhone API列表?

  2. 是否有针对某些API的第三方袖外文档?

3 个答案:

答案 0 :(得分:4)

您可以使用classdump获取iPhone SDK的列表,但我不知道第三方文档的存在(非)。不过,你可以通过阅读他们的名字来了解方法的作用。

答案 1 :(得分:2)

Erica Sadun,最受尊敬的iPhone黑客之一有一本关于此的书。大多数未记录的头文件也可以从她的网站上提取。

答案 2 :(得分:0)

我找到了一个perl脚本(source = arstechnika),它构建了一个来自iPhone SDK的公共框架和私有框架的标头文件夹。但是我得到一个错误(类转储失败,返回16777215 ),如果我运行它。

    #!/usr/bin/perl
#
# 24 November 2008
# Framework Dumping utility; requires class-dump
#

use strict;

use Cwd;
use File::Path;

my $HOME = (getpwuid($<))[7] || $ENV{'HOME'} 
  or die "Could not find your home directory!";

# This command must be in your path.
# http://www.codethecode.com/projects/class-dump/
my $CLASS_DUMP = 'class-dump'; 

# Public Frameworks
dump_frameworks('/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/Frameworks',
                'Frameworks');

# Private Frameworks
dump_frameworks('/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/System/Library/PrivateFrameworks',
                'PrivateFrameworks');

sub dump_frameworks
{
  my($dir, $subdir) = @_;

  opendir(my $dirh, $dir) or die "Could not opendir($dir) - $!";

  # Iterate through each framework found in the directory
  foreach my $file (grep { /\.framework$/ } readdir($dirh))
  {
    # Extract the framework name
    (my $fname = $file) =~ s/\.framework$//;
    print "Framework: $fname\n";

    my $headers_dir = "$HOME/Headers/$subdir/$fname";

    # Create the folder to store the headers
    mkpath($headers_dir);

    # Perform the class-dump
    my $cwd = cwd();
    chdir($headers_dir) or die "Could not chdir($headers_dir) - $!";

    system($CLASS_DUMP, '-H', "$dir/$file");

    if(my $ret = $? >> 8)
    {
      die "$CLASS_DUMP failed, returning $ret\n";
    }

    chdir($cwd) or die "Could not chdir($cwd) - $!";
  }
}