0

I'm trying to determine the architecture of another file from my application. I'm using my application bundle and comparing it to a different bundle in my example. The methods are in place and they do return values to NSLog, although they are not the values I was expecting. Can anyone make some sense as to how to interpret the returned values?

- (void)whatArch {

        NSArray *x86_64_Arch = [[NSBundle mainBundle] executableArchitectures];
        NSArray *i386_Arch = [[NSBundle bundleWithPath:@"/path/to/other/bundle"] executableArchitectures];
        NSLog(@"%@ %@",[x86_64_Arch componentsJoinedByString:@" "], [i386_Arch componentsJoinedByString:@" "]);

}

The output I get is:

2012-07-09 00:00:59.990 whatArch[2200:403] 16777223 7 18

The [16777223] is the value that returns for the x86_64 bundle, and [7 18] for the (other) i386 bundle. When I read the documentation on executableArchitecture it shows something much different:

Mach-O Architecture

These constants describe the CPU types that a bundle’s executable code may support.

enum {
   NSBundleExecutableArchitectureI386      = 0x00000007,
   NSBundleExecutableArchitecturePPC       = 0x00000012,
   NSBundleExecutableArchitectureX86_64    = 0x01000007,
   NSBundleExecutableArchitecturePPC64     = 0x01000012
};
4

1 回答 1

2
NSLog(@"%u 0x%x", 0x01000007, 16777223);    // Prints 16777223 0x1000007
NSLog(@"0x%x %u", 18, 0x00000012);    // Prints 0x12 18

我将把 7 和 0x7 作为练习留给读者。

你知道圣诞节(12 月 25 日)和万圣节(10 月 31 日)实际上是同一天吗?

于 2012-07-09T20:50:39.607 回答