• 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: Initializing an Array
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Initializing an Array


  • Subject: Re: Initializing an Array
  • From: Jeff Galyan <email@hidden>
  • Date: Tue, 22 Jan 2002 15:06:32 -0700

On 1/22/02 2:57 PM, "John C. Randolph" <email@hidden> wrote:
>
> Okay, in the interest of making your life easier:
>
> 1) since you're going to be done with the c string before you
> return from the method where you're creating it, go ahead and
> use -cString instead of -getCString:.
>
> - (const char *)cString
>
> Returns a representation of the receiver as a C string in the
> default C string encoding. The returned C string will be
> automatically freed just as a returned object would be released;
> your code should copy the C string or use getCString: if it
> needs to store the C string outside of the autorelease context
> in which the C string is created.

I tried this, and it *always* causes a segfault on my box.

>
> and
>
> 2) if you need to find the length of an NSString in order to
> manually allocate space for it's c-string representation, use
> -cStringLength, not -length.

I didn't know about this method - thanks!


--Jeff


References: 
 >Re: Initializing an Array (From: "John C. Randolph" <email@hidden>)

  • Prev by Date: Re: Initializing an Array
  • Next by Date: Embedded database engine in Cocoa?
  • Previous by thread: Re: Initializing an Array
  • Next by thread: Re: Initializing an Array
  • Index(es):
    • Date
    • Thread