• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: UInt8 > NSString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: UInt8 > NSString
      • From: Bob Smith <email@hidden>
    • Re: UInt8 > NSString
      • From: "Clark Cox" <email@hidden>
    • Re: UInt8 > NSString
      • From: Chris Suter <email@hidden>
References: 
 >shortcut for selecting in NSPopUpButton (From: email@hidden)
 >UInt8 > NSString (From: arri <email@hidden>)
 >Re: UInt8 > NSString (From: Bob Smith <email@hidden>)

  • Prev by Date: Re: NSToolbar Bug [SOLVED - At Least Partially]
  • Next by Date: Screensaver question
  • Previous by thread: Re: UInt8 > NSString
  • Next by thread: Re: UInt8 > NSString
  • Index(es):
    • Date
    • Thread