Main Page | Report this Page
Computers Forum Index  »  Computer Languages (Objective-C)  »   at (no spam) property declaration...
Page 1 of 1    

at (no spam) property declaration...

Author Message
Linda...
Posted: Tue Aug 04, 2009 2:15 pm
Guest
Trying to understand creating getters and setters using the at (no spam) property
declaration.

I was listening to the Intro to Objective-C and Cocoa Touch video from
iTunes.

Here is the earlier line of code

-(void)setParents:(NSArray *)parents;

Here is the equivalent line of code

at (no spam) property(readwrite) NSArray *parents;

I understand about the readwrite being the default and that it does
not need to be used. I understand about the at (no spam) property now. What I
don't understand is the proper use of parenthesis. In the first there
is (NSArray *)parents; and in the replacement (equivalent) code, it is
NSArray *parents without any parenthesis.

Any advice on this?

Linda
 
Reinder Verlinde...
Posted: Tue Aug 04, 2009 6:38 pm
Guest
In article
<6d04ade5-2d9d-4e91-bdb4-913d584d78c5 at (no spam) s15g2000yqs.googlegroups.com>,
Linda <1anmldr1 at (no spam) gmail.com> wrote:

Quote:
Trying to understand creating getters and setters using the at (no spam) property
declaration.

I was listening to the Intro to Objective-C and Cocoa Touch video from
iTunes.

Here is the earlier line of code

-(void)setParents:(NSArray *)parents;

Here is the equivalent line of code

at (no spam) property(readwrite) NSArray *parents;

I understand about the readwrite being the default and that it does
not need to be used. I understand about the at (no spam) property now. What I
don't understand is the proper use of parenthesis. In the first there
is (NSArray *)parents; and in the replacement (equivalent) code, it is
NSArray *parents without any parenthesis.

Any advice on this?

Other than "You will not win a fight with a compiler over language

syntax"?

That is just the way you tell the compiler to do that. You could just as
well have asked why that second method needs that ' at (no spam) ', or why both need
that semicolon at the end.

There probably is a highly pragmatic reason for having the parentheses
in the first line. It might prevent an ambiguity somewhere, or make the
language parser easier to write, but as a user of the language, you
should not care.

Not having parentheses in the second version probably is because of its
similarity to a normal field:

at (no spam) property(readwrite) NSArray *parentsAsAProperty;
NSArray *childrenAsAField;

Reinder
 
Preston...
Posted: Tue Aug 04, 2009 9:00 pm
Guest
On 2009-08-04 08:15:25 -0600, Linda <1anmldr1 at (no spam) gmail.com> said:

Quote:
Trying to understand creating getters and setters using the at (no spam) property
declaration.

I was listening to the Intro to Objective-C and Cocoa Touch video from
iTunes.

Here is the earlier line of code

-(void)setParents:(NSArray *)parents;

Here is the equivalent line of code

at (no spam) property(readwrite) NSArray *parents;

I understand about the readwrite being the default and that it does
not need to be used. I understand about the at (no spam) property now. What I
don't understand is the proper use of parenthesis. In the first there
is (NSArray *)parents; and in the replacement (equivalent) code, it is
NSArray *parents without any parenthesis.

Any advice on this?

Linda

It's just how the syntax was defined by Apple, for whatever reasons.
 
Tom Harrington...
Posted: Tue Aug 04, 2009 11:08 pm
Guest
In article <2009080411000075249-preston at (no spam) stupidcom>,
Preston <preston at (no spam) stupid.com> wrote:

Quote:
On 2009-08-04 08:15:25 -0600, Linda <1anmldr1 at (no spam) gmail.com> said:

Trying to understand creating getters and setters using the at (no spam) property
declaration.

I was listening to the Intro to Objective-C and Cocoa Touch video from
iTunes.

Here is the earlier line of code

-(void)setParents:(NSArray *)parents;

Here is the equivalent line of code

at (no spam) property(readwrite) NSArray *parents;

I understand about the readwrite being the default and that it does
not need to be used. I understand about the at (no spam) property now. What I
don't understand is the proper use of parenthesis. In the first there
is (NSArray *)parents; and in the replacement (equivalent) code, it is
NSArray *parents without any parenthesis.

Any advice on this?

Linda

It's just how the syntax was defined by Apple, for whatever reasons.

I suspect the property declaration has that syntax because it's sort-of
like a variable declaration. So they made the syntax like a
declaration, plus extra stuff at the beginning. The method declaration
is a very different thing, so it's not surprising it has a different
syntax.

--
Tom "Tom" Harrington
Independent Mac OS X developer since 2002
http://www.atomicbird.com/
 
Preston...
Posted: Tue Aug 04, 2009 11:55 pm
Guest
On 2009-08-04 13:08:21 -0600, Tom Harrington
<tph at (no spam) pcisys.no.spam.dammit.net> said:

Quote:
In article <2009080411000075249-preston at (no spam) stupidcom>,
Preston <preston at (no spam) stupid.com> wrote:

On 2009-08-04 08:15:25 -0600, Linda <1anmldr1 at (no spam) gmail.com> said:

Trying to understand creating getters and setters using the at (no spam) property
declaration.

I was listening to the Intro to Objective-C and Cocoa Touch video from
iTunes.

Here is the earlier line of code

-(void)setParents:(NSArray *)parents;

Here is the equivalent line of code

at (no spam) property(readwrite) NSArray *parents;

I understand about the readwrite being the default and that it does
not need to be used. I understand about the at (no spam) property now. What I
don't understand is the proper use of parenthesis. In the first there
is (NSArray *)parents; and in the replacement (equivalent) code, it is
NSArray *parents without any parenthesis.

Any advice on this?

Linda

It's just how the syntax was defined by Apple, for whatever reasons.

I suspect the property declaration has that syntax because it's sort-of
like a variable declaration. So they made the syntax like a
declaration, plus extra stuff at the beginning. The method declaration
is a very different thing, so it's not surprising it has a different
syntax.

I agree that it's probably intended to mimic the declaration of an
instance variable. Maybe Apple also didn't want so many parenthesis
next to each other.
 
 
Page 1 of 1    
All times are GMT
The time now is Mon Nov 23, 2009 4:20 pm