• 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
Newbie Question: Find spaces inside a string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Newbie Question: Find spaces inside a string


  • Subject: Newbie Question: Find spaces inside a string
  • From: Julian Sanchez <email@hidden>
  • Date: Tue, 25 Oct 2005 23:10:46 -0500

Hello,

I recently started reading Hillegass' book on cocoa programming. I just finished Aaron's challenge at the end of chapter 4 in which you need to write a small application that allows a user to enter text, and you tell the user how many letters are contained in the text.

Easy enough since the "length" method in NSString does the job for you.

However, I tried to be a bit smart here and provide additional functionality in which if a user enters a sentence (with its corresponding spaces) I would like to find that out and count only the letters.

First thing that came to mind was to write a loop that would use NSString:characterAtIndex, traversing the string one character at a time.

My question is: Surely there's a better (and quicker) way to do this, isn't it? What way is that?

Thanks for your help,
Julian

_______________________________________________
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


  • Follow-Ups:
    • Re: Newbie Question: Find spaces inside a string
      • From: Douglas Davidson <email@hidden>
    • Re: Newbie Question: Find spaces inside a string
      • From: Manfred Bergmann <email@hidden>
    • Re: Newbie Question: Find spaces inside a string
      • From: Prachi Gauriar <email@hidden>
  • Prev by Date: Re: NSPanel vs. NSFontPanel and font color
  • Next by Date: Re: NSPanel vs. NSFontPanel and font color
  • Previous by thread: Re: Document Architecture question - newbie
  • Next by thread: Re: Newbie Question: Find spaces inside a string
  • Index(es):
    • Date
    • Thread