How to declare a class with Objective-C ?

Code Block
//
//  main.m
//  TowergraphOS
//
//  Created by Besleaga Alexandru Marian on 5/12/21.
//
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
    @autoreleasepool {
        // insert code here...
        NSLog(@"Hello, World!");
    }
    return 1;
}


I want to declare class NSObject for class initializing.

Assuming that you’re using Xcode, do this:
  1. Choose File > New > File.

  2. At the top of the resulting sheet, select your platform.

  3. Select Cocoa Class (the exact name will be different for each platform but it’s always the second item in the list) and click Next.

  4. Set the Language popup to Objective-C.

  5. Set the “Subclass of” popup to the class you’re trying to subclass, or NSObject otherwise.

  6. Give it a name — in this example I’m going to call it Test — and click Next.

  7. Choose a location to save it.

  8. Things now vary depending on whether you’re generally working in Swift or Objective-C:

  • If you’re working on Swift, Xcode may ask you whether you want to create a bridging header. If it does, agree to that. Next add #include "Test.h" to that header.

  • If you’re working in Objective-C, add #include "Test.h" to the top of the .m file where you need to use this class.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
How to declare a class with Objective-C ?
 
 
Q