Assuming you have an
NSString, please read the
class reference for it. There are two instance methods it has that are specifically built for what you're looking for.
P.S. And by "in Xcode", we have to assume you mean "using Objective-C". If not, you should let us know. Remember, accuracy is important, both in programming and getting help in a programming forum.