Newbie Question: Find spaces inside a string
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