Core Data property declaration

  • The following new document on Core Data property
    declarations contains an example that I hope is wrong:
    http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles
    /cdAccessorMethods.html


    The document shows
    @property(retain) NSString* firstName, lastName;

    This is a pet peeve of mine.  Surely, the example
    should be
    @property(retain) NSString *firstName,  *lastName;

    Note the "*lastName".  The extra asterisk makes ALL
    the difference in C, and the asterisk is NOT
    associated with the type name, it is associated with
    the variable and should/must be grouped with the
    variable.

    Is the document correct or am I.  I am away from any
    Leopard machine, so I can't just test it.
  • On Nov 1, 2007, at 6:32 PM, Erik Buck wrote:

    > The following new document on Core Data property
    > declarations contains an example that I hope is wrong:
    > http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles
    /cdAccessorMethods.html

    > The document shows
    > @property(retain) NSString* firstName, lastName;
    > This is a pet peeve of mine.  Surely, the example
    > should be
    > @property(retain) NSString *firstName,  *lastName;
    >
    Gah, yes, it should be.  Thank you.
    It'll be corrected in the next release.

    mmalc
  • On Nov 2, 2007, at 10:32 , Erik Buck wrote:

    > [deleted]

    > Note the "*lastName".  The extra asterisk makes ALL
    > the difference in C, and the asterisk is NOT
    > associated with the type name, it is associated with
    > the variable and should/must be grouped with the
    > variable.

    The * makes ALL the difference as you say, but it needn't be "grouped"
    in terms of textual format, just properly associated with the variable
    name. Assuming @property follows C syntactic rules. either of the
    following should be fine:

    @property(retain) NSString *firstName,  *lastName;
    @property(retain) NSString* firstName,  * lastName;

    Though I like the first syntax better for aesthetic reasons (that
    second variable looks odd in the second line, with the * in empty
    space).

    The mental trick I use to keep track of what associates with what in
    "typename *varname;" is: "*varname is an instance of typename, so
    varname is a reference to typename".

    ScottB

    > Is the document correct or am I.  I am away from any
    > Leopard machine, so I can't just test it.
    >
previous month november 2007 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today