Re: UInt8 > NSString
Re: UInt8 > NSString
- Subject: Re: UInt8 > NSString
- From: "Clark Cox" <email@hidden>
- Date: Mon, 5 Mar 2007 16:52:43 -0800
On 3/5/07, arri <email@hidden> wrote:
On Mar 5, 2007, at 21:22 31, Bob Smith wrote:
> The suggestion from others to return an NSString * instead is the
> better solution. But just so you know, the problem here is a basic
> C memory management error. Your function is returning an automatic
> variable, which becomes undefined out of scope of the function.
> What you need to do is change:
>
> char addr[12]
>
> to
>
> static char addr[12]
>
> and it would work.
i guess that that is why i was getting getting this --function
returns address of local variable-- warning?
> However this is not thread-safe since the same static space would
> be used in any thread calling the function.
> Hope this helps!
yes, it helps:) as i wrote, i implemented the main-function as an obj-
c method
of the class that was calling the function. this methods then calls
the statically declared functions
and creates an NSString from the returned bytes. seems perfectly
threadsafe.
It isn't. In fact, it is pretty much the textbook example of
non-threadsafe code.
--
Clark S. Cox III
email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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