Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

problem with NSString, UTF8, pathnames



To my surprise:
an NSString returned by Cocoa will cause NSLog to crash.
Details:

I override 'openDocumentWithContentsOfURL:display:error'
in order to see what is happening.
The NSURL (absoluteURL) passed in comes from Cocoa's normal open file dialog.
so:
 NSString *s = [absoluteURL description];  // make NSString from NSURL
 NSLog(s);  // often works, sometimes crashes.

I think the  problem is that the pathname is UTF8-encoded,
but has not been properly decoded when it arrives in string 's'.

On the web I found methods to create NSStrings from c-strings
and from UTF8-encoded strings; but I don't find a way to reverse the process.

Seems like a bug to me, that Coca will create an object
that will create description than will crash when passed to NSLog.
(Maybe it will be gone tomorrow, thanks to Leopard & XCode 3.0)

But whatever, is there a workaround, or must I consider this as harmful?
    NSLog( [validCocoaObject description] );
_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.