<ios Tips > Return to parent Directory Operations GoBack () method

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.