Re: NSArray's objectAtIndex compiles to objectAtIndexedSubscript?
Re: NSArray's objectAtIndex compiles to objectAtIndexedSubscript?
- Subject: Re: NSArray's objectAtIndex compiles to objectAtIndexedSubscript?
- From: Bill Cheeseman <email@hidden>
- Date: Sun, 09 Mar 2014 08:21:50 -0400
These are the two framework class methods that were called:
+ (void)initialize {
if (self == [PFUIElement class]) {
// Accessibility API bug workaround support.
isFixedMenuActionBug = ([self QSWStandardizedOperatingSystemVersion] >= versionMenuActionBugFixed);
....
+ (unsigned long)QSWStandardizedOperatingSystemVersion { // private
// Returns the system version as an unsigned long integer in BCD format in the form "0x00MMmmbb", where MM is the major release, mm is the minor release, and bb is the bugfix release, padded with leading zeroes as needed to ensure two-digit fields. Obtains the system version from the string in the ProductVersion entry in the SystemVersion.plist file at /System/Library/CoreServices/SystemVersion.plist, which may be in the format "10.8.5" or "10.9". Returns 0 in the event of an error such as failure to find the SystemVersion.plist file.
// Use the %x or %X string format specifiers with +[NSString stringWithFormat:] in NSLog calls. This code adapted from Steve Christensen http://lists.apple.com/archives/carbon-dev/2005/Oct/msg00788.html.
NSString *errorDesc = nil;
NSPropertyListFormat format;
NSString *rootPath = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSSystemDomainMask, YES) objectAtIndex:0]; // <-- -objectAtIndex: call
NSString *plistPath = [rootPath stringByAppendingPathComponent:@"CoreServices/SystemVersion.plist"];
if (![[NSFileManager defaultManager] fileExistsAtPath:plistPath]) return 0;
NSData *plistXML = [[NSFileManager defaultManager] contentsAtPath:plistPath];
NSDictionary *contents = (NSDictionary *)[NSPropertyListSerialization propertyListFromData:plistXML mutabilityOption:NSPropertyListMutableContainersAndLeaves format:&format errorDescription:&errorDesc];
if (!contents) return 0;
NSString *versionString = [contents objectForKey:@"ProductVersion"];
NSArray *versionComponentStrings = [versionString componentsSeparatedByString:@"."];
static unsigned long sBCDSystemVersion = 0;
SInt32 majorVersion = ([versionComponentStrings count] >= 1) ? [versionComponentStrings[0] intValue] : 0;
SInt32 minorVersion = ([versionComponentStrings count] >= 2) ? [versionComponentStrings[1] intValue] : 0;
SInt32 bugFixVersion = ([versionComponentStrings count] >= 3) ? [versionComponentStrings[2] intValue] : 0;
sBCDSystemVersion = ((majorVersion / 10) << 20) |
((majorVersion % 10) << 16) |
((minorVersion / 10) << 12) |
((minorVersion % 10) << 8) |
((bugFixVersion / 10) << 4) |
((bugFixVersion % 10) << 0);
return sBCDSystemVersion;
}
--
Bill Cheeseman - email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden