• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: ObjC question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ObjC question


  • Subject: Re: ObjC question
  • From: Dan Treiman <email@hidden>
  • Date: Mon, 21 Feb 2011 15:02:14 -0600

[(*node) left] is an _expression_, thus &[*node left] doesn't make sense for the same reason that &(x + 1) wouldn't make sense.

It might work to re-use the BTreeNode ** node pointer -- this might be what you want, if you are trying to pass back the final node into which n is inserted:

-(void) insert: (BTreeNode **) node node:(BTreeNode *) n
{
…

// get the address of the left member 
      *node = [*node left];
[self insert:node node:n];
}

Or, if my above assumption was wrong, you could create a new pointer on the stack:

-(void) insert: (BTreeNode **) node node:(BTreeNode *) n
{
…

// get the address of the left member 
      BTreeNode * leftChild = [*node left];
[self insert:&leftChild node:n];
}


As a footnote, questions like this should probably go to Cocoa Developers <email@hidden>. 

hope this was helpful,
-Dan Treiman

On Feb 21, 2011, at 2:19 PM, Tony Romano wrote:

I have this object definition:

@interface BTreeNode : NSObject
{
NSObject *item;
BTKey *key;
BTreeNode *left;
BTreeNode *right;
}

@property (assign) NSObject *item;
@property (assign) BTKey *key;
@property (assign) BTreeNode *left;
@property (assign) BTreeNode *right;

I have a method that has this signature:
-(void) insert: (BTreeNode **) node node:(BTreeNode *) n;

I'm trying to do this:

-(void) insert: (BTreeNode **) node node:(BTreeNode *) n
{
…

// get the address of the left member 
[self insert:&[(*node) left] node:n];  // <--- error
}

The compiler(GCC 4.2 or LLVM 1.6) is giving this error : address _expression_ must be an lvalue or a function designator.

I was assuming the return value for [[(*node) left]] is a lvalue (it's a pointer) and I should be able to obtain the address of that pointer but either you can't or the value returned from the message call to node is not a lvalue.

This, [(*node) left], returns the correct object; however, I need to know the address of the object to pass in.  What is the proper syntax?

Thanks in Advance,
-Tony
Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >ObjC question (From: Tony Romano <email@hidden>)

  • Prev by Date: Re: ObjC question
  • Next by Date: Re: ObjC question
  • Previous by thread: Re: ObjC question
  • Next by thread: Re: ObjC question
  • Index(es):
    • Date
    • Thread