• 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: trouble getting c-chars from NSString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: trouble getting c-chars from NSString


  • Subject: Re: trouble getting c-chars from NSString
  • From: Shawn Erickson <email@hidden>
  • Date: Thu, 31 Mar 2005 13:38:18 -0800


On Mar 31, 2005, at 1:12 PM, Daniel Child wrote:

Actually, your suggestion is precisely what I ended up using. However, I did have to use a C-String to paste the characters together because I did not find a method that does "stringFromChars." Here was my approach.

unichar c;
char noNums[100];

noNums[numNewChars++] = c;

A unichar is not a char. The former is 2 bytes (defined as an unsigned short) the later is 1 byte in size so you are losing data in the above operation.

printf("%s", [numFree cString]);

You can print an NSString directly using NSLog(@"%@", numFree), it is a bad idea to get a c string from an NSString since an NSString supports characters that cannot be expressed in a ASCII character set.

Can you restate exactly what you are trying to accomplish?

I am not talking about code but what your are trying to do with a string you have, what you want at the end, etc.

-Shawn
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >trouble getting c-chars from NSString (From: Daniel Child <email@hidden>)

  • Prev by Date: Re: NSAttributedString saved into NSUserDefaults
  • Next by Date: Re: trouble getting c-chars from NSString
  • Previous by thread: trouble getting c-chars from NSString
  • Next by thread: Re: trouble getting c-chars from NSString
  • Index(es):
    • Date
    • Thread