NSString methods

NSString is a class that developers use a lot. Like all Objective-C classes, it comes with useful methods. If you want to do something with a string, there is likely an NSString method that can help.

Below are a few examples of NSString methods. To introduce these methods, we are showing you the declaration of the method and then an example of it being used. The declaration tells you what you need to know about a method: whether it is an instance or a class method, what it returns, its name, and the types of its arguments, if any.

To get the number of characters in a string, you use the length method:

-​ ​(​N​S​U​I​n​t​e​g​e​r​)​l​e​n​g​t​h​;​

This method is an instance method. You can tell by the ‘-’ at the ...

Get Objective-C Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.