Re: Best Way to Handle Properties?
Re: Best Way to Handle Properties?
- Subject: Re: Best Way to Handle Properties?
- From: Jason Coco <email@hidden>
- Date: Tue, 19 Aug 2008 14:24:26 -0400
On Aug 19, 2008, at 13:02 , Dave wrote:
My specific questions are:
Is the NSString allocation and initWithCharacters code the best way
to do this? If so, what would the setter look like in this case? If
not what is a better way of doing it?
Hey Dave,
I don't think that initWithCharacters is what you want... that expects
an array of unichar characters, which isn't what you said you had.
Since you're doing the encoding in your other function, and you know
what it is, just use the initWithBytes function and the specific
encoding. For example (assuming your byte array was in UTF-16BE:
char *buf = /* initialized and filled somewhere else */
size_t buf_len = /* set somewhere else */
NSString *myString = [[NSString alloc] initWithBytes:buf
length:buf_len encoding:NSUTF16BigEndianStringEncoding];
Just remember, the length is the actual number of bytes (including the
0x00 bytes in the array), not the number of code points or the number
of characters.
/Jason
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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:
This email sent to email@hidden