Amazon.com Widgets @property syntax question?
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 22, 2013, 12:13:19 AM
Home Help Search chat Login Register   
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+  Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+  Old Stuff
| |-+  Chapter Study
| | |-+  Chapter 7 - More on Classes
| | | |-+  @property syntax question?
Pages: [1]   Go Down
Print
Author Topic: @property syntax question?  (Read 742 times)
Semaj
Newbie
*
Posts: 8






« on: February 11, 2011, 12:26:20 PM »

What are the rules for declaring data types in the @property statement?

For example, why does the following syntax work

@property int numerator, denominator;

While this syntax throws an error

@property int numerator, int denominator;

What if you are using more than one data type (ie int and string)?
Logged
scokar
Newbie
*
Posts: 10






« Reply #1 on: February 11, 2011, 02:03:27 PM »

I think you can use the following for syntehsizing setter/getter variables of different types:


Code: (Objective-C)
@interface myClass: NSObject
{
     int myInt;
     int yourInt;
     NSString * myString;
{
@property int myInt, yourInt;
@property NSString *myString;

@end
Logged
Semaj
Newbie
*
Posts: 8






« Reply #2 on: February 21, 2011, 01:00:26 PM »

Does anyone know the syntax rules for @property?  Why does the following statement generate an error?

@property int numerator, int denominator;
Logged
skochan
Administrator
Hero Member
*****
Posts: 3103







« Reply #3 on: February 21, 2011, 07:15:05 PM »

The type of the property is only listed once.  You need to write it like this:

Code: (Objective-C)
@property int numerator, denominator;

Cheers,

Steve Kochan
Logged
Pages: [1]   Go Up
Print
Jump to:  



Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.