checking if an object's instance exists.
checking if an object's instance exists.
- Subject: checking if an object's instance exists.
- From: Aaron Boothello <email@hidden>
- Date: Sat, 05 Feb 2005 13:45:45 +0800
I've subclasses NSObject for a custom class by the name of 'myObject'.
An instance of 'myObject' is called 'object1'.
I allocate memory and initialize the instance like this:
object1 = [[myObject alloc]init];
And release it like this:
[object1 release];
At one point in my code, i need to access the instance, but it could happen that the object hasnt been allocated or initialized. how do i check ?
my block of code looks something liek this:
-(void)method1
{
[release object1];
[self method2];
}
-(void)method2
{
int x;
if(object1)
x=[object1 length];
}
but it dosent seem to work.
basically i need to check if the instance object1 exists or not.
Any suggestions ?
Cheers,
Aaron
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden