Amazon.com Widgets Sythesize vs. Multiple Arguments to a Method
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 21, 2013, 07:37: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
|-+  Programming in Objective-C, 4th edition
| |-+  Chapter 7
| | |-+  Sythesize vs. Multiple Arguments to a Method
Pages: [1]   Go Down
Print
Author Topic: Sythesize vs. Multiple Arguments to a Method  (Read 604 times)
roque32
Newbie
*
Posts: 1






« on: March 29, 2012, 06:01:37 PM »

Hi,

In chapter 7, the Synthesize and Multiple Arguments to a Method was introduced.  It is my understanding that when use @property and @synthesize, you no longer have to create the setters and getter methods.  I'm also guessing that this is thrown out the window when you are sending multiple arguments to a method.  Am I correct about this?

Thanks,
Ron
Logged
francis21
Newbie
*
Posts: 2






« Reply #1 on: April 04, 2012, 03:51:39 PM »

Using the
Code: (Objective-C)
 @property 
and
Code: (Objective-C)
 @synthesize 
directives to your instance variables creates the appropriate accessor methods for you. Sometimes making your own accessor methods is ideal to some situations, but most likely you'll be using these directives so that the compiler can generate the required accessor methods for you.

Also remember that you can also specify how objects are stored to your instance variables in your
Code: (Objective-C)
 @property 
directive like so:
Code: (Objective-C)
 @property (nonatomic, strong) ... 
.
Logged
rue
Jr. Member
**
Posts: 53






« Reply #2 on: April 24, 2012, 12:17:04 AM »

Hi,

In chapter 7, the Synthesize and Multiple Arguments to a Method was introduced.  It is my understanding that when use @property and @synthesize, you no longer have to create the setters and getter methods.  I'm also guessing that this is thrown out the window when you are sending multiple arguments to a method.  Am I correct about this?

Thanks,
Ron

This is my understanding.

A "property" is always a single value. Numerator, Denominator, Length, Width, Height... you get the idea.
So @synthesize will only set/get that single property. Makes sense. It saves a lot of work from creating setters/getters that only modify that one variable.

If you want to create a method that needs to pass 2 values, you can't synthesize this. You'd have to create  your own custom method for it, with the multiple parameters/arguments explicitly defined.
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.