Objective-C Language Classes and Objects

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

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


Got any Objective-C Language Question?