Re: Initializing Structures

2014-11-05 Thread Kyle Sluder
On Wed, Nov 5, 2014, at 04:11 PM, Greg Parker wrote: > The C language allows a struct variable to be initialized in its > declaration using the brace syntax, but does not allow that form to be > used anywhere else. > > C99 adds this syntax ("compound literal") that works anywhere: > > NSView

Re: Initializing Structures

2014-11-05 Thread Greg Parker
> On Nov 5, 2014, at 2:03 PM, Richard Charles wrote: > > A fast and compact way to initialize a structure is to enclose the values in > a pair of braces like this. > > NSRect rect = {{0,0},{80,20}}; > NSView *view = [[NSView alloc] initWithFrame:rect]; > > However a compiler error occ

Initializing Structures

2014-11-05 Thread Richard Charles
A fast and compact way to initialize a structure is to enclose the values in a pair of braces like this. NSRect rect = {{0,0},{80,20}}; NSView *view = [[NSView alloc] initWithFrame:rect]; However a compiler error occurs if we try to initialize a struct with braces directly within an O