On Dec 1, 2008, at 10:46 PM, Dave DeLong wrote:

I've got some NSData objects that I'd like to hard code into a file (they're encoded images for some example factory methods). The reason I need to hard code them is that I need to be able to reconstruct these images on both the Mac and the iPhone, and I thought that getting the TIFFRepresentation of the 32x32 version and then some how hard coding it into my factory class would be "simplest".

If possible, I'd like to avoid compiling in image files, because in the future I'm planning on being able to accept any image encoded into an NSData (ones that won't be hard coded), and I'd like to have the built-in presets follow the same format.

Trying to represent a large binary object as a constant string in your source code strikes me as a bad idea. It strikes me as a really bad idea when there are better alternatives.

If you want NSData to be the lingua franca in your class design, I'd still go with a bundle resource and use something such as (written in mail, caveat emptor):

+ (NSData *)factoryImageData
{
NSString *path = [[NSBundle mainBundle] pathForResource: @"MyImage" ofType: @"tiff"];
        return [NSData dataWithContentsOfFile: path];
}

Jim

_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to