Amazon.com Widgets Program 8.4 - avoid the dot notation
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 23, 2013, 09:26:36 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 8 - Inheritance
| | | |-+  Program 8.4 - avoid the dot notation
Pages: [1]   Go Down
Print
Author Topic: Program 8.4 - avoid the dot notation  (Read 644 times)
dennishenley
Newbie
*
Posts: 12






« on: September 30, 2011, 07:43:23 AM »

Is there a way to not use the dot notation for Program 8.4? Specifically the line:

Code: (Objective-C)
NSLog(@"Origin at (%i, %i)", myRectangle.origin.x, myRectangle.origin.y);

I tried using the [] notation like this:

Code: (Objective-C)
NSLog(@"Origin at (%i, %i)", [myRectangle [origin x]], [myRectangle [origin y]]);

This produces the error Use of undeclared identifier 'origin'. The dot notation does not produce an error and the program runs fine.

Any ideas?
Logged
fujilla
Global Moderator
Sr. Member
*****
Posts: 270


WWW




« Reply #1 on: September 30, 2011, 08:09:53 AM »

You were nearly there, but not quite:

[[myRect origin] x]

Nick
http://myfirstiphoneapp.co.uk
http://easyintervalsapp.co.uk
Logged
dennishenley
Newbie
*
Posts: 12






« Reply #2 on: September 30, 2011, 08:34:42 AM »

Thanks. I understand now.

Dennis
Logged
CloudDweller
Newbie
*
Posts: 17






« Reply #3 on: March 11, 2012, 04:23:27 AM »

Is there a difference between using myRect.width and [myRect width] or are they both interchangeable?  Also when is it good practice to use one and not the other?
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.