I know its a very basic question. Got some memory issues I need to clarify. Here is my doubt:
int *p = malloc (50); // will allocate 50 bytes and it is pointed by p.
// Freeing C pointer-->
free(p);
Objective-C pointers:
ClassAobject *objA = .... // allocated ClassAobject..
// Freeing obj-C pointer--->
objA = nil // Is it enough??? will it release all ivars memory properly..
what if the case, If I have some C pointers inside the objective C class? How to handle this in ARC
The title doesn’t reflect what you’re asking. There’s no difference between C pointers and “Objective-C pointers”. Really they’re just plain ol’ C pointers.
What you’re asking for is the difference between their correct usage. If a pointer points to an Objective-C object, then under MRC, you have to do
to decrease its reference count (which can potentially deallocate it). Under ARC, setting the pointer to
nilis enough (as in your example).