Jerry Krinock wrote:
Now, please understand that I'm not sure whether or not it's kosher to add +initialize in a category on a Cocoa class

Don't add +initialize in a category. The category's method will replace any present in the original class, which could break that class. However, I don't think that matters for NSString.


but the interesting thing is that when I run this in Leopard, seven classes (it's a "cluster", I suppose) are initialized without complaint...

When I run this in Panther, ten classes are initialized (looks like Apple has trimmed some of the fat since then), but in the first four of them, +initialize seems to run before there is an autorelease pool...

NSString (and most of the other toll-free bridged classes) is very special. CoreFoundation and the Objective-C runtime jump through hoops to make toll-free bridging work. The mechanisms used have changed in almost every Mac OS X release, so it's no surprise that you see different behavior on Panther and Leopard. And NSStrings are used very early, before main(), so it's also no surprise that there's no autorelease pool around yet.


http://www.cocoabuilder.com/archive/message/cocoa/2008/3/21/201996


I'm not convinced that your crash is caused by your category. Unfortunately, I have no sufficiently old ppc hardware handy to test any theories. You didn't post the full crash log, but it looks like the crash is a call to [@"name" copyWithZone:NULL]. If so, it dies because the string's isa pointer is NULL. The implementation of constant strings has changed in the past, so it could be that the binary built on Leopard doesn't match the constant string implementation on Panther.

What happens if you compile your code with -fno-constant-cfstrings?

What happens if you copy the contents +crashMe into - applicationDidFinishLaunching: , and omit the call to +crashMe completely?

What happens if you do the above, and also delete your NSString category?

What happens if you call `[@"name" copyWithZone:NULL]` directly, from either +crashMe or -applicationDidFinishLaunching:


--
Greg Parker     [EMAIL PROTECTED]     Runtime Wrangler


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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