O'Reilly logo

Objective-C Quick Syntax Reference by Matthew Campbell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 7

image

Numbers

NSNumber

NSNumber is the class used in Objective-C to work with numbers. NSNumber gives you a way to turn floating point and integer values into object-oriented number objects. While you can’t use NSNumber objects in expressions, NSNumber objects become useful when complicated formatting is required.

NSNumber objects can be created with many different constructors, but the most common way you’ll see NSNumber objects created is with the @ symbol followed by a number.

NSNumber *num1 = @1;NSNumber *num2 = @2.25;

Sometimes you may want to use special constructors that are matched to numbers stored in a particular way.

NSNumber *num3 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required