0

NSString, NSBool, and NSInteger come with a lot of extra functionality that is nice when needed, but becomes baggage when unnecessary. Is there a lightweight way to hold on to strings like there is for bool and int?

  • NSBool has BOOL
  • NSInteger has int

What does NSString have?

Jacksonkr
  • 31,583
  • 39
  • 180
  • 284

2 Answers2

6

NSInteger is just a raw C-type (just like int -- and, to be precise about it, NSInteger is a typedef to either long or int depending on architecture), and there is no such thing as NSBool. You're probably thinking about NSNumber objects.

NSString objects, on the other hand, are really easy to hold onto and work with. Yes, you can get the raw bytes and put them into a "const char *", but if you're working with Objective C, you'll find there are less headaches to leave strings as Objective C objects rather than C pointers.

Community
  • 1
  • 1
Michael Dautermann
  • 88,797
  • 17
  • 166
  • 215
4

You can use const char *

bames53
  • 86,085
  • 15
  • 179
  • 244