0
votes
  1. I am new in objective c and also in development field, and i want to know that when we quit our application then os automatically release or finish our resources that we retain during our application so why we need to do it explicitly(release or autorelease in obj c)?

  2. My second question is that i am facing problem in when i release object of app delegate class in rootViewcontroller class in dealloc method then my program is crash when again i am going to go in controller class like follwing.

    -(void) viewDidLoad { TestAppDelegate * object = (TestAppDelegate *)[[UIApplication sharedApplication]delegate]; }

    -(void)dealloc {[object release]; [super dealloc];}

1
The above code won't even compile, much less crash - object is local to the -viewDidLoad method, and attempting to use it in -dealloc results in a compile error. If you want real help, please post real code.Sherm Pendley

1 Answers

2
votes
  1. You should release or autorelease objects in order to make all the objects execute their -()dealloc's. When process finishes OS clears all the memory occupied by process but it cannot clear some other resources (mutexes, semaphores, maybe something else) because they are kernel objects and might be used by different processes. So OS cannot know whether to delete these objects as initial process finished. Developer should clear such objects himself and this is done usually in dealloc methods of proper objects.

  2. It's not clear when crash happens. Could you clarify?