Re: plist help?
Re: plist help?
- Subject: Re: plist help?
- From: Lance Drake <email@hidden>
- Date: Sat, 20 Sep 2003 13:22:08 -0600
char* cstr = (char*)[filename cString];
Note that when something is declared to return a (const char *),
casting it to a (char *) is not a good idea, as the compiler will no
longer catch potentially invalid modifications of that string.
Hi Ali,
Bless you kind sir for taking the time to show me the error of my
ways. Actually, I wish I hadn't included any of that ancillary code
and simply said, "You might use one o'them XML conversion routines'.
More importantly, please, do not use the cString method for extracting
8-bit file names from NSStrings. It just won't work with international
file names, and in some user environments, it might even fail to work
with plain old ASCII.
Unicode is the answer to these and so many other problems. In the
words of Ed MacMahon, "You are cor-RECT sir!"
In fact, do not use cString and related methods at all, as they are
being deprecated.
For filenames, if you must extract them as 8-bit, use the NSString
method fileSystemRepresentation, declared in NSPathUtilities.h.
But what's even better is if you can avoid extracting 8-bit strings
from NSStrings as much as possible. For instance everything you are
doing in your code you can do with the functionality in
NSPropertyListSerialization.h and NSData.h
Well, the original letter made mention of the confusion factor he was
encountering with the NSPropertyListSerialization object. My thought
was to provide an alternate solution. Again, if I had just stuck to a
'check out the XML conversion routines', I would have been better off.
Ali - Obviously, you know your stuff - thanks for sharing.
Lance Drake
_______________________________________________
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.