Skip navigation.
 
mlhow to check if a property is empty?
FROM : Davide Benini
DATE : Sat Mar 29 16:32:54 2008

Hello folks.
I have a class with a number of properties. Some of them are used only 
in specific instances. I need to check whether these properties have 
been assigned a value; I am thinking about a method similar to isset 
in php.
I alloc and init properties in the genral init methid; I release them 
in the dealloc method.

- (void) dealloc
{
   [repetitions release];
   [variantEnding release];

   [body release];
   [super dealloc];
}
- (id) init
{
   self = [super init];
   if (self != nil) {
       repetitions = [[NSNumber alloc] init];
       variantEnding = [[NSNumber alloc] init];
       body = [[NSMutableArray alloc] init];
   }
   return self;
}

I assign their value when it is needed.
Let's say I have an instance of this class, called *thisObject. How do 
I check whether I have assigned a value to thisObject.variantEnding or 
if the property is inialized but empty?
This is probably a noob question, but I couldn't find an answer in the 
docs.
Thanks in advance.
Davide

Related mailsAuthorDate
mlhow to check if a property is empty? Davide Benini Mar 29, 16:32
mlRe: how to check if a property is empty? Quincey Morris Mar 29, 18:04
mlRe: how to check if a property is empty? Davide Benini Mar 29, 18:11
mlRe: how to check if a property is empty? Jens Alfke Mar 29, 18:16
mlRe: how to check if a property is empty? Jens Alfke Mar 29, 18:22