Removing all punctuation and placing remaining words into array
I'm trying to take the text typed or pasted into a searchbar and remove all punctuation and separate each individual word and place it in an array. This is as close as I've gotten but there are a lot of empty entries in the array where the punctuation was.
i can show you how to remove the punctiation easily.. i dont understand the rest.. are you trying to detect a word and then put a space???
anyways...
lets say you have a UITextView called mytextfield1 ... if it has a comma in it.. you can replace that comma with a space.... (.m file)
I'm trying to take the text typed or pasted into a searchbar and remove all punctuation and separate each individual word and place it in an array. This is as close as I've gotten but there are a lot of empty entries in the array where the punctuation was.
__________________ UK Flights
Latest UK Flight information right in your iPhone/iPod Touch. All major UK Airports are available in this brilliant iPhone Application. Download from the iTunes Store.
I changed it a bit and it seems to be accepting input and it places it correctly (I think) in the array. But, when I try to get an object from the array to update a TableViewCell text, I get EXC_BAD_ACCESS.
I have a declared NSArray called components in my header file.
I think it may be because the objects in the components array are not strings? I don't know how to change them or use them as strings if that is the case. Appreciate all the help you all have been so far! Thanks!
Then make sure to release the array when you're done with it.
I added that first line and no difference. However, I added a [components retain]; right before the [table reloadData]; and that did the trick. Although I am still confused where or why it was getting released before the cells could update?
I think I may have narrowed it down to only happen between words that have multiple spaces, symbols, or numbers. a single space or single punctuation mark seem to be handled properly.
I think I may have narrowed it down to only happen between words that have multiple spaces, symbols, or numbers. a single space or single punctuation mark seem to be handled properly.
Any ideas?
Read my previous post and find out where I have used componentsJoinedByString
__________________ UK Flights
Latest UK Flight information right in your iPhone/iPod Touch. All major UK Airports are available in this brilliant iPhone Application. Download from the iTunes Store.
Remember that you can not use == to see if a string is empty. You also can not insert nil/null into an array as it will raise an exception and the program will crash.
I haven't written the above code in XCode. I just wrote it here so it might have some syntax errors but I think you get the idea. Make sure you use [NSString length] instead of what you did. Best of luck.
__________________ UK Flights
Latest UK Flight information right in your iPhone/iPod Touch. All major UK Airports are available in this brilliant iPhone Application. Download from the iTunes Store.