struct
a collection of types, composite data type, composition, "user-definded data structure"
struct Test {
char* name;
int nr;
float f;
};
Name of type is "struct Test", and not "Test" alone.
struct Test myNewTest
Semicolon after closing parethesis is essentional.
Access composed types with dot-syntax:
myNewTest.name = "hjkjnk";
myNewTest.nr = 32;
myNewTest.f = 2.2424
;
typedef
a shorthand, an alias for a type, for ease of readability.
typedef int MyType
"MyType n;" would be equal to "int n;"
enum
"introduces a symbolic name for an integer constant"
enum direction_enum {LEFT, RIGHT};
/ LEFT -> 0, RIGHT -> 1; /
enum direction_enum x = LEFT;
typedef enum
typedef enum {
LEFT;
RIGHT;
} direction;
declatation:
-(void)myFunction:(direction)LEFTorRIGHT;
call:
-(void)myFunction:LEFT;
typedef struct
typedef struct objectInfo_ {
CGPoint origin;
NSString name;
NSColor color;
} objectInfo
Shortcut. Instead of writing 'struct objectInfo', write 'objectInfo'. The keyword 'objectInfo' seems to be optional.