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 *view = [[NSView alloc] > initWithFrame:(NSRect){{0,0},{80,20}}]; >
The compound literal syntax is also a lot more flexible: it can initialize members by name; they can be initialized out of order; members in nested structs can be initialized directly; and all members that are not initialized explicitly are initialized to zero. What I'm saying is, it's really handy and you should look it up. --Kyle Sluder _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com