1

I need to tokenize many strings on an iPhone. Obviously, resources are at a minimum. I have been using componentsSeparatedByCharactersInSet: to tokenize my strings, but it is slow. Would it be better to use NSScanner? What, generally, are the guidelines one should follow when choosing to use one or the other to tokenize?

Jason
  • 14,517
  • 25
  • 92
  • 153
  • The only way to tell if NSScanner is faster than componentsSeparatedByString is to try it both ways and measure the performance. – JeremyP Mar 01 '11 at 09:13

1 Answers1

2

IMHO NSScanner is way more flexible than componentsSeparatedByCharactersInSet, so if you need more flexibility - use NSScanner. Regarding performance - you'd have to test for that. So if NSScanner is faster - it has flexibility AND performance advantage (although disadvantage on ease of use).

Eimantas
  • 48,927
  • 17
  • 132
  • 168