Re: UInt8 > NSString
Re: UInt8 > NSString
- Subject: Re: UInt8 > NSString
- From: arri <email@hidden>
- Date: Tue, 6 Mar 2007 00:47:35 +0100
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.
(but i'll still need to study my kernighan and ritchie bible alot..)
thanks
arri
_______________________________________________
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