Differences between "Obj-C in iOS App Development" and "Obj-C in MacOS CommandLine Development"

Hi guys!

I'm using Swift in developing applications for iOS. Currently, I'm interested in learning Objective-C to build applications. However, when I create a project with Obj-C, I found out that, there are some differences between using "Obj-C in iOS Dev" and "Obj-C in MacOS CommandLine". For instance: declaring method;

  • iOS Dev Environment:
    • -(void)getFunc {..}
  • macOS Dev Environment:
    • void getFunc() {...}

You can see here, there are -(void) and void only.

Anyway, can you recommend some documents to study Objective-C?

Thank you for spending time for my post! Have a great day!

Best regard from Vietnam!

Answered by szymczyk in 737931022

Objective-C takes the C language and adds support for object-oriented programming.

The function example you showed for iOS is an example of an Objective-C method. A method is a function that is part of a class. Objective-C methods put the return type in parentheses, (void). Objective-C has two types of methods: instance and class. An instance method starts with - while a class method starts with +. You showed an example of an instance method.

The function example you showed for Mac is an example of a C function. Objective-C supports C functions. C functions do not put the return type in parentheses. C does not have classes so it does not have methods.

Apple provides the following guide to Objective-C:

https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html

The following book teaches Objective-C for people who already know Swift:

https://www.hackingwithswift.com/store/objective-c-for-swift-developers

Accepted Answer

Objective-C takes the C language and adds support for object-oriented programming.

The function example you showed for iOS is an example of an Objective-C method. A method is a function that is part of a class. Objective-C methods put the return type in parentheses, (void). Objective-C has two types of methods: instance and class. An instance method starts with - while a class method starts with +. You showed an example of an instance method.

The function example you showed for Mac is an example of a C function. Objective-C supports C functions. C functions do not put the return type in parentheses. C does not have classes so it does not have methods.

Apple provides the following guide to Objective-C:

https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html

The following book teaches Objective-C for people who already know Swift:

https://www.hackingwithswift.com/store/objective-c-for-swift-developers

In addition to the (excellent) reply above...

Only macOS has command line tools. Not iOS nor iPadOS.

And macOS fully supports C functions and Objective C classes and methods. Same as do iOS and iPadOS.

Thank you guys for such of useful support! I understood it clearly :) Thank you and hope you guys have a best day!

Differences between "Obj-C in iOS App Development" and "Obj-C in MacOS CommandLine Development"
 
 
Q