Skip navigation.
 
mlRe: how to check if a property is empty?
FROM : Jens Alfke
DATE : Sat Mar 29 18:16:31 2008

On 29 Mar '08, at 8:32 AM, Davide Benini wrote:

>         repetitions = [[NSNumber alloc] init];
>         variantEnding = [[NSNumber alloc] init];


These lines don't really make sense. NSNumber (like its superclass 
NSValue) is immutable. You can't store a different number in one once 
you've created it. So there's no need to create one unless you have a 
specific number to store. Just don't set the variable at all, and its 
value will be nil. (That will let you know if you've set it, too.)

However, more typically you'd just use a regular C numeric type like 
'int' or 'double' for a numeric property. That way you don't have to 
allocate or release the value, it uses less memory, and it's simpler 
to access the value.

—Jens

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