Re: Checksum of App/NIB
Re: Checksum of App/NIB
- Subject: Re: Checksum of App/NIB
- From: Charles Srstka <email@hidden>
- Date: Sat, 3 Aug 2002 13:58:27 -0500
On Saturday, August 3, 2002, at 10:28 AM, Itrat Khan wrote:
On Friday, August 3, 2001, at 10:56 AM, Luke Sands wrote:
So can someone tell me how to get a path to one of the class.nib /
info.nib etc which is in a nib bundle which is in my app bundle....
Your best bet is to load the desired nib file using NSFileWrapper and
checksum the resulting NSData representation. To get the nib file, you
can either hard-code it using NSBundle's pathForResource:@"mynib"
ofType:@"nib" or use NSDirectoryEnumerator to search for all files in
your application directory with a .nib extension.
Don't do this!
I tried that not long ago, and it turns out that if the path to the app
changed, so did the data returned by -[NSFileWrapper
serializedRepresentation]. So the app would work just fine in my build
folder, but when I sent it to anyone else, the path it ended up in would
not be the same, and they would get a checksum mismatch.
Just do this:
NSString *bundlePath = [[NSBundle mainBundle] pathForResource:@"mynib"
ofType:@"nib"];
NSMutableData *nibData = [NSMutableData data];
[nibData append
Data:[NSData dataWithContentsOfFile:
[bundlePath stringByAppendingPathComponent:@"classes.nib"]]];
[nibData append
Data:[NSData dataWithContentsOfFile:
[bundlePath stringByAppendingPathComponent:@"info.nib"]]];
[nibData append
Data:[NSData dataWithContentsOfFile:
[bundlePath stringByAppendingPathComponent:@"objects.nib"]]];
Then get a checksum on nibData.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.