Syntax
- Cat *cat = [[Cat alloc] init]; // Create cat object of type Cat
- Dog *dog = [[Dog alloc] init]; // Create dog object of type Dog
- NSObject *someObject = [NSObject alloc];
[someObject init]; // don’t do this
- XYZObject *object = [XYZObject new]; // Use new to create objects if NO arguments are needed for initialization
- NSString *someString = @"Hello, World!"; // Creating an NSString with literal syntax
- NSNumber *myFloat = @3.14f; // Another example to create a NSNumber using literal syntax
- NSNumber *myInt = @(84 / 2); // Create an object using a boxed expression