Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Objective-c > ObjectiveC cons...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 897 of 1039
Post > Topic >>

ObjectiveC constructors / destructors.

by SpreadTooThin <bjobrien62@[EMAIL PROTECTED] > Aug 28, 2007 at 08:31 PM

I'm mixing Objective-C and C++ in a .mm / .h files
I am not exactly great at ObjectiveC, particularly when it comes to
object creation and destruction.
My understanding is there are few methods for Object creation on OC.
For instance (No pun intended)
MyOCObject * x = [[MyOCObject alloc] init]  at a later time [x
release]
Then there are factory objects, which I don't think I need anymore as
all this has been depricated into a new memory contract with commands
like new and delete or free...
Looking at my class below in the C++ class I have an pointer to an
ObjectiveC object that is not initialized until My C++ class is
constructed,
at which point I want to properly construct the OC Object and when my C
++ class destructor is call I want to free its instance.

I'm reading:

http://docs.mandragor.org/files/Programming_languages/Objective-C/Objective-C_Infrequently_Asked_Questions_en/q3.htm

at the moment to see if I can clarify this.

class MyClass
{
private:
	MyObjectiveCObject *	_inquiry;
	BOOL				_busy;
};

MyClass::MyClass
{
	_inquiry = [MyObjectiveCObject new]
	_busy = FALSE;
}

MyClass::~MyClass
{
	[_inquiry delete];
}
 




 2 Posts in Topic:
ObjectiveC constructors / destructors.
SpreadTooThin <bjobrie  2007-08-28 20:31:54 
Re: ObjectiveC constructors / destructors.
David Phillip Oster <o  2007-08-29 05:10:06 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Oct 10 20:00:54 CDT 2008.