Passing a pointer to a function in objective-c

Posted by Chiodo on Stack Overflow See other posts from Stack Overflow or by Chiodo
Published on 2010-06-11T10:03:03Z Indexed on 2010/06/11 10:12 UTC
Read the original article Hit count: 178

Filed under:
|
|

Hi, i've a stupid questiona about passing pointer.

I've this:

@interface MyClass : NSObject
myobj* foo;
-(void)doSomething:(myobj*)aObj;
@end

@implementation MyClass
-(void)doSomething:(myobj*)aObj
{
  cFuncCall(&aObj); //alloc memory and init the object
}

-(id)init
{
  //init stuff...
  [self doSomething:foo]; // foo retun 0x0!!!
}
@end

why foo return nil??? It should be initialized by cFuncCall!

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c