I have an UIViewController with scalar ivars. I would like to know what will happen when a controller will receive a memory warning.
testBool will be kept without changes or will be reseted ?
class.h
@interface myView : UIViewController
{
BOOL testBool;
}
When you receive a memory warning, YOU need to react to it. The system will try to help you (freeing VC’s views and calling loadView / viewDidLoad again when needed) but you need to take care of all your objects.
Speaking of objects.. if you define “BOOL*” this will be a pointer.. i don’t think you really want this (you will need to allocate some memory and assign this memory address to testBool so you can access the real scalar value with *testBool = YES/NO and free this memory on [self dealloc]).
In general, cocoa memory management applies to OBJECTS only. If you mess around with pointers to scalars you have to deal yourself with memory (de)allocation. You should use scalar ivars or Foundation-Types like NSNumber. If you use ARC, you don’t even have to care a lot about the memory management (retain/release). Only when you receive memory warnings, you should assign
nilto the variables (ARC will handle the memory management).