Goback () method function: Return to the upper level interface, by judging whether the popviewcontrolleranimated type is empty, to judge is present or pop out, and then directly do the releaseself operation;
- (void) GoBack
{
Idslog(@ "Self:%@, Parent:%@", Self, [ SelfParentviewcontroller]);
IDpage = [ SelfPresentingviewcontroller];
Idslog(@ "Presenting page:%@", page);
ID VC = [self. Navigationcontroller popviewcontrolleranimated : YES ]; idslog(@ "Pop the =%@", VC); if (Nil= = VC) {
[ Selfdismissviewcontrolleranimated:YESCompletion:^{
}];
}
[ Selfreleaseself];
}releaseself () method function: Used to release the notification memory, and the GoBack () method combined to prevent forgetting to release the default notification;
- (void) releaseself
{
//sub class implements.
Idslog(@ "Self:%@", Self);
[[NsnotificationcenterDefaultcenter] Removeobserver: Self];
}
PS: In front of each file to add these two sentences to release memory statements
- (void) Dealloc
{
Idslog(@ "Dealloc-idsgameroomhomepage");
}
- (void) releaseself
{
[Superreleaseself];
}Second, my idea GoBack this method, the use is very convenient, and notice the memory leak, before writing, each time to correspond to push or present to write the return operation, now a [self GoBack] is done, I think this is a relatively convenient and not prone to problems of a good way. Third, thinking and action 1.Goback method is there a problem with this writing? If so, do you think of a better solution? What's the difference between 2.releaseSelf and dealloc? Why is there dealloc still need releaseself method? Where is the disadvantage of synthesizing a method?
<ios Tips > Return to parent Directory Operations GoBack () method