views:

2535

answers:

4

My code is: dvController.selectedCountry = selectedCountry;

Why do I get the error "request for member 'selectedCountry' in something not a structure or union"?

+7  A: 

You are probably trying to access a property "selectedCountry" on an object, and you forgot to include that header file. (At least that's what I usually do wrong when I get this error.)

pix0r
Argh! Thanks...
bmoeskau
A: 

also if the types are NOT the same you can get this message. Casting to the right type usually resolves this.

ennuikiller
+1  A: 

I suspect that dvController is a pointer (to a structure) and not the structure. You need to use '->' instead of '.', perhaps.

Jonathan Leffler
I can't verify this, but I do not think the -> is used frequently in objective-c, iphone programming.
TahoeWolverine
Hmmm...now you mention it, I'm not sure either. However, I know that the GCC (as opposed to the Objective-C compiler) will produce that error when you try to use '.' instead of '->'.
Jonathan Leffler
A: 

I believe that I have encountered this problem when I have a member or variable that hasn't properly been initialized. Check to make sure that each of your objects has memory and is initialized properly.

Also, your question isn't as clear as it could be since there is the local variable selectedCountry and the member. Which one is being referred to here? I would assume the member, if the variable is actually a member of whatever is "self" that might be your problem. Whenever I program, I make sure to make distinctions between locals, members of the current class, and members of other classes so that it's easy to see what's going on when bugs come up. Just a thought.

TahoeWolverine