Amazon.com Widgets why no getters in 3.2
Welcome, Guest. Please login or register.
Did you miss your activation email?
October 21, 2014, 09:46:13 PM
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 3 - Classes, Objects, and Methods
| | | |-+ why no getters in 3.2
Pages: [1] Go Down
Print
Author Topic: why no getters in 3.2 (Read 843 times)
skronwith
Newbie
*
Posts: 17


Email




on: September 15, 2011, 09:02:13 PM

In program 3.2, setters are made (eg setNumerator) but there are no getters, as in 3.4, so my newbie question is why does 3.2 work?  I thought that you could only write numerator and get back the value if you either wrote the getter method or synthesized numerator previously.  Why does the NSLog statement in 3.2 not give an error when numerator and denominator are used instead of getters?  Thanks.
Logged
dharr19
Full Member
***
Posts: 175


Email




Reply #1 on: September 15, 2011, 09:15:15 PM

Hi,

Instance variables declared in the interface section of a class are known to the methods of that same class.
In this case the print method knows about numerator and denominator.  Now if we want to obtain the value of numerator and denominator inside the main body of the program then we need some way to access those variables - this is where the setter and getter methods come in.

Let me know if this helps
David
Logged
skronwith
Newbie
*
Posts: 17


Email




Reply #2 on: September 16, 2011, 02:02:22 PM

Thanks very much.  I understand now.
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.