views:

75

answers:

2

Hi there,

I've one application and two lib files. Application initialize a class object which need to pass to another class which is in the library. How can i do that? Here is what i did but it just crash

mainClass.h

@interface mainUIDelegate: NSObject<UIApplicationDelegate>
{
 bla bla...
 myCppClass myCppObject;
}

mainClass.mm

-(void)viewDidLoad{
 myCppObject = new myCppClass();
}

-(void)initObject:(id)sender
{
 prefTableViewController *prefs = [[prefTableViewController alloc] initWithStyle:UITableViewStyleGrouped];

prefs.myCppObject = myCppObject;

}

library 1 (myCppClass.h) (with cpp class object)

class myCppClass{
int a;
}myCppClass;

library 2 (prefTableViewUI.h)

@interface prefTableViewController:UITableViewController{
myCppClass myCppObject;
}
@property (nonatomic, assign) myCppClass myCppObject;

Can someone please let me know how can i pass such object? I've just a month experience in object C.

A: 

Indeed more information is needed on what/where exactly crash. Not knowing how your class is defined, I'd say the property looks suspicious. You want to try to create a method first, say -[prefTableViewController setMyCppObject:] with the argument type being myCppClass*, and then implement the method as myCppObject = *argument.

(One sideway suggestion, though purely stylistic matter: Upper-casing the first letter of your Objective-C class name will help tell which is which)

lukhnos
A: 

I resolved this, the problem was lying in sythensizing the object. I had forgot to synthesize the object.

iamiPhone