Re: Custom zones...
Re: Custom zones...
- Subject: Re: Custom zones...
- From: "charlie" <email@hidden>
- Date: Tue, 10 Aug 2010 18:01:43 +0000
In an effort to simplify the example, I may have made it more complicated.
I'm actually trying to create an NSSecureTextField, but I tried to make
the example more apple-vs-apples, by showing a c string and an NSString
back to back.
I tried with:
NSSecureTextField
NSTextField
NSButton
NSString
All fail to allocate within the custom zone.
Of these classes, I think only NSString is part of a cluster, so
something else has to be at fault here too.
The CF solution is great. Thanks for that. Good to know. But, I
guess I need to know how to allocate the backing store for the string
storage for an NSSecureTextField in a custom zone still.
I was hoping that I could simply allocate the text field itself from
the custom zone and it would internally allocate its string storage
from the same zone.
I guess I could subclass NSSecureTextField and provide my own string
storage using the CF methodology you mentioned.
(task: to ensure that the string storage is encrypted, and wiped clean
before it's deallocated)
Thanks again.
Chuck
On August 10, 2010 04:31:26 A.M. EDT, Alastair Houghton
<email@hidden> wrote:
On 10 Aug 2010, at 05:18, charlie wrote:
As you can see, the c string is successfully allocated from space in
the custom zone. But the NSString object is allocated from the
default zone, despite having called +[NSObject allocWithZone:].
Anyone know the trick to this?
Sounds like a bug to me. While zones are *discouraged* (they're very
definitely an advanced topic and easily misused), I don't think
they're actually deprecated.
Anyway, the solution is to drop down a layer to Core Foundation. You
can make an allocator that will use an NSZone easily enough using
CFAllocatorCreate(), then pass that into CFStringCreate() as the
allocator argument.
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
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