views:

180

answers:

1

I'm trying to set up an NSinvocation to upload a picture to a website. I'm doing this:

  1. Set up the nsinvocation object
  2. Add a UIImage* to the nsinvocation object as an argument, along with some other arguments
  3. invoke the nsinvocation when needed
  4. the function called when I invoke nsinvocation can't access the UIImage- I get NSInvalidArgumentException.

After digging for a little while, It looks like if I add a UIImage as an argument to my NSInvocation object, then try to get it back out... I am returned a different memory address! Is this normal?

//First I have a valid UIImage "imgHolder" which has a memory address of "A"...

NSInvocation *myInvocation = [NSInvocation invocationWithMethodSignature:...

[myInvocation setArgument:imgHolder atIndex:5];

//Now, the weird part...

UIImage *checkImg;

[myInvocation getArgument:&checkImg atIndex:12];

//checkImg has a memory address of "B"!

if I try to work with checkImg, I get various exceptions which leads me to believe it's not a valid UIImage.

Any ideas what's going on? Shouldn't the memory address of checkImg be identical to that of imgHolder?

+1  A: 

[myInvocation setArgument:imgHolder atIndex:5];

If imgHolder is a UIImage*, you should pass &imgHolder, not imgHolder.

Rüdiger Hanke
Oops. =) Thanks.(If they didn't make the 7 button so hard to reach when holding shift, this probably wouldn't happen so often...)