Peter Warbo
Peter Warbo

Reputation: 11748

Objective-C different syntaxes question

I'm learning Objective-C at the moment so bear with me.

As I understand the general syntax (except when using properties) when coding Objective-C looks something like this:

[object method];
[object methodWithArgument:1 arg2:2];

Now to my confusion when reading upon file input/output for iOS devices, the example tells me to use a method to get the Application's documents folder:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

What is going on here?

Upvotes: 2

Views: 111

Answers (2)

Dan F
Dan F

Reputation: 17732

The first syntax is for calling member methods of a class, the second is for invoking standalone functions. Objective-c is a superset of C meaning it has all of the features of C (including functions) along with the OO features of classes and the like

Upvotes: 0

Philippe Leybaert
Philippe Leybaert

Reputation: 171924

The first is Objective C syntax for calling methods

The second snippet uses C syntax for calling functions.

Objective C is a superset of C

Upvotes: 6

Related Questions