[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: passing address of an object of type id
From: |
glen e. p. ropella |
Subject: |
Re: passing address of an object of type id |
Date: |
Wed, 16 Oct 1996 11:40:43 -0600 |
> I created a list of type id just like in heatBugList. Now, I want ot pass
> its address to some method. I'm doing it like this.
>
> in *.h file
> -----------
> id partList;
>
> in *.m file
> -----------
>
> -setPartList: (id *)p{
> partList=p;
> return self;
> }
>
> My program is compiling with a warning message "assignment from
> incompatible pointer type". Can any one explain it to me. I appreciate
> your time. I haven't seen any example in the above format. So, I guess I
> messed it up.
>
> -Naga Krothapalli
> address@hidden
Hi Naga.
Well, it looks to me like partlist is of type "id," not "id *,"
which means "pointer to an id."
What you may be missing is the fact that (id) is a pointer already.
Using it to pass things into functions is analogous to declaring a
type in C like:
struct xyz_type{
int booga;
float ooga;
};
typedef struct xyz_type *p_xyz_type;
main()
{
p_xyz_type pxyz;
struct xyz_type booga;
pxyz = &booga;
....
}
This makes p_xyz_type a pointer to a structure of type xyz.
In objective C, an "id" is a pointer to an object. An object
is, itself, a structure.
So, basically, just take the "*" out of the setPartList definition
and prototype and it should work.
glen