Updating to 10.6SDK

By: | Post date: November 17, 2009 | Comments: No Comments
Posted in categories: Cocoa
Tags: ,

After completing the conversion to 64-bit, MagicBrush-Photo is “broken” since it also relies on the 10.4 SDK and some behavior has changed in 10.6. Here are a few of the issues and problems that had to be overcome.

Static Analyzer

Once I get an initial compile of the program, I immediately see some compiler warnings and some strange behavior, so I compile and analyze using the Clang Static Analyzer that is now included with the XCode tools.

“Boom” 111 opportunities to review.

What a great way to catch up on code you haven’t looked at in two years. I really do suggest it.

External Frameworks

I use several external frameworks including eSellerate for my embedded webstore. Naturally, there are new versions of these frameworks that need to be incorporated to get a clean build under 10.6.

The frameworks:

Deprecated Methods

There are many methods that have been deprecated since the original 10.4 build of the app.  Here they are for history.

+ (void)setKeys:(NSArray *)keys triggerChangeNotificationsForDependentKey:(NSString *)dependentKey

Configures the receiver to post change notifications for a given property if any of the properties specified in a given array changes. (required) (Deprecated in Mac OS X v10.5 and later. You should use the method keyPathsForValuesAffectingValueForKey: instead.)

Under 10.6 the preferred method is found here

You can also achieve the same result by implementing a class method that follows the naming convention keyPathsForvaluesAffecting, where is the name of the attribute (first letter capitalized) that is dependent on the values. Using this pattern the code in Listing 1 could be rewritten as a class method named keyPathsForValuesAffectingFullName as shown in Listing 2.

Listing 2 Example implementation of the keyPathsForValuesAffecting naming convention

+ (NSSet *)keyPathsForValuesAffectingFullName


return [NSSet setWithObjects:@”lastName”, @”firstName”, nil];


+ (id)stringWithCString:(const char *)cString

Creates a new string using a given C-string. (Deprecated in Mac OS X v10.4. Use stringWithCString:encoding: instead.)

– (void)getCString:(char *)buffer

Invokes getCString:maxLength:range:remainingRange: with NSMaximumStringLength as the maximum length, the receiver’s entire extent as the range, and NULL for the remaining range. (Deprecated in Mac OS X v10.4. Use cStringUsingEncoding: or dataUsingEncoding:allowLossyConversion: instead.)

– (NSArray *)directoryContentsAtPath:(NSString *)path

Returns the directories and files (including symbolic links) contained in a given directory. (Deprecated in Mac OS X v10.5. Use contentsOfDirectoryAtPath:error: instead.)

– (BOOL)createDirectoryAtPath:(NSString *)path attributes:(NSDictionary *)attributes

Creates a directory (without contents) at a given path with given attributes. (Deprecated in Mac OS X v10.5. Use createDirectoryAtPath:withIntermediateDirectories:attributes:error: instead.)

– (BOOL)copyPath:(NSString *)source toPath:(NSString *)destination handler:(id)handler

Copies the directory or file specified in a given path to a different location in the file system identified by another path. (Deprecated in Mac OS X v10.5. Use copyItemAtPath:toPath:error: instead.)

+ (CIContext *)contextWithCGLContext:(CGLContextObj)ctx pixelFormat:(CGLPixelFormatObj)pf options:(NSDictionary *)dict

Creates a Core Image context from a CGL context, using the specified options and pixel format object. (Deprecated in Mac OS X v10.6.)

A solution was found by looking at this sample code.

Next up, Window/View Behavior….