• 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: dealing with different types of strings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dealing with different types of strings


  • Subject: Re: dealing with different types of strings
  • From: Douglas Davidson <email@hidden>
  • Date: Wed, 16 Jan 2002 12:17:39 -0800

On Wednesday, January 16, 2002, at 11:29 AM, Josh Ferguson wrote:

I'm trying to find the best method of taking input from a TextField and
converting it to a Pascal String to be inserted as parameters in a
library function. I can't find a way to get the value from the text
field as a Pascal string, so I thought of storing it to an NSString,
then using the getCString (or just cString) method to store it to a char
* (this may be an extra step), then using CopyCStringToPascal() to copy
the char * to a Str255 *... I was hoping there was an easier method for
accomplishing this...anyone have any ideas? I come from a Unix /
Windows background, so dealing with Pascal strings is totally foreign to
me...

The CoreFoundation type CFString has functions for obtaining a Pascal string directly from a CFString. Furthermore CFString and NSString are bridged, so a non-nil NSString * can be cast to a CFStringRef and used with the CFString functions. You will need to specify the encoding you want; this is preferable to using cString and not knowing what encoding you will get.

Douglas Davidson


  • Prev by Date: Re: NSTextview don't update
  • Next by Date: Re: How to deal with long pathnames in Cocoa ?
  • Previous by thread: Re: dealing with different types of strings
  • Next by thread: Re: dealing with different types of strings
  • Index(es):
    • Date
    • Thread