Amazon.com Widgets Program 8.4 - NSLogs
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 19, 2013, 08:51:27 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 8 - Inheritance
| | | |-+  Program 8.4 - NSLogs
Pages: [1]   Go Down
Print
Author Topic: Program 8.4 - NSLogs  (Read 600 times)
MCaEd
Newbie
*
Posts: 47






« on: November 13, 2011, 08:49:02 PM »

Hello,
I don't understand how to interpret these two NSLogs:
Code: (Objective-C)
NSLog (@"Rectangle w = %i, h = %i", myRect.width, myRect.height);
NSLog (@"Origin at (%i, %i)", myRect.origin.x, myRect.origin.y);
What does myRect.width mean? Using the knowledge of dot operator - set width of myRect?!
Also, how do you explain myRect.origin.x?
I've read once again about dot operator on pages 129-130 but don't see it answering.
Thanks in advance
Logged
skochan
Administrator
Hero Member
*****
Posts: 3103







« Reply #1 on: November 13, 2011, 08:52:40 PM »

myRect.width is the same as [myRect width]

myRect.origin.x is the same as [[myRect origin] x]

Cheers,

Steve
Logged
MCaEd
Newbie
*
Posts: 47






« Reply #2 on: November 13, 2011, 08:58:35 PM »

However, width and x are not methods but rather instant variables, so how can you use them that way?
Logged
skochan
Administrator
Hero Member
*****
Posts: 3103







« Reply #3 on: November 14, 2011, 08:35:44 AM »

Yes, they are methods you wrote or are synthesized.  They are getter methods that correspond to the instance variable names.

Cheers,

Steve
Logged
MCaEd
Newbie
*
Posts: 47






« Reply #4 on: November 14, 2011, 09:02:36 AM »

Oh, yes, they are. I've just read the code again. Thank you for the clarification, Steve!
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.