Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why declare types for each object variable in Objective-C? [closed]

Tags:

objective-c

Since Objective-C is a dynamic typing language, why do we still need types? Is the reason because it mixes with C code?

like image 713
lingguang1997 Avatar asked Aug 28 '13 17:08

lingguang1997


1 Answers

Objective-C is not mixed with C, it's a proper superset of C with some dynamic features.

You can avoid the use of static typing on any Objective-C object variable and declare everything as id, but I don't see why would you want to do that.
You would lose all the help the compiler is giving you thanks to the type information (provided or inferred).

To wrap it up, you don't need types, you want types.

like image 75
Gabriele Petronella Avatar answered Nov 10 '22 22:11

Gabriele Petronella