Welcome, Guest. Please login or register.
Did you miss your activation email?
July 26, 2016, 11:01:06 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
| |-+ Help!!!
| | |-+ Request for member in something not a structure or union
Pages: [1] Go Down
Author Topic: Request for member in something not a structure or union (Read 15932 times)
Full Member
Posts: 173

on: May 09, 2009, 03:32:15 PM

I get this as an error

Request for member 'denominator' in something not a structure or union

when I try and compile the following code.

Code: (Objective-C)
-(id) add: (id) f
// To add two fractions
// a/b + c/d = ((a*d) + (b*c)) / (b * d)

// result will store the result of the addition
id result = [[Fraction alloc] init];
int resultNum, resultDenom;

resultNum = numerator * f.denominator + denominator * f.numerator;
resultDenom = denominator * f.denominator;

[result setTo: resultNum over: resultDenom];
[result reduce];

return result;

When I stop using the dot syntax for f.denominator in favour of [f denominator] everything works fine. Can someone please help me understand why one is Ok and the other isn't?

I've used this code before but when I changed it to accept and return id objects it stopped working as it used to.


Last Edit: May 11, 2012, 08:06:26 AM by happyzhb Logged
Hero Member
Posts: 3114

Reply #1 on: May 09, 2009, 03:45:45 PM

The compiler is fussy when you use the dot operator on an id variable.  It doesn't like the fact that it doesn't know the object's type.  Stick to the [....] notation in such cases.


Full Member
Posts: 173

Reply #2 on: May 09, 2009, 03:56:39 PM

Seems really weird but I guess it depends on how the compiler operates. Just a little quirk I'll need to get used to.

Thanks Steve.
Pages: [1] Go Up
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.