Objective-c dealloc boolean value

How do I deallocboolean?

Disabling this method below gives me a warning: Incompatible pointer to an integer conversion assigning "BOOL" (aka 'signed char') from 'void *'

- (void)dealloc {
    self.booleanVar = nil;
    [super dealloc];
}

Perhaps I should clarify this from a simple class inherited from NSObject.

I use the self.var = nil template that you see in Cocoa Touch classes. Say, if it were NSString *, should I use self.var = nil or [var release] in the method instead dealloc? I'm a little confused here.

+3
source share
3 answers

. . , ( NULL ) -.


, . , , , , .

NSString * , . , , NSString. , , . , , , . dealloc, "" , , , .

+10

BOOL, BOOL - , . , .

+2

, booleanVar BOOL, :

BOOL booleanVar;

, , , , . booleanVar dealloc .

, BOOL, :

BOOL *booleanVar;

non, NULL nil, NULL nil ( . NULL vs nil Objective-C).

However, if you want to free the memory pointed to by a pointer BOOLallocated with mallocor realloc, etc., then try the free()C function (see http://www.cplusplus.com/reference/clibrary/cstdlib/free/ ).

What would all this be if you showed us the property declaration for booleanVar in the class interface, which tells us exactly what you want to do, and you get the answer with complete confidence.

0
source

All Articles