Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 698805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:19:00+00:00 2026-05-14T03:19:00+00:00

Need some best practice advice here… Navigation based application. Root view is a UITableView

  • 0

Need some best practice advice here…

Navigation based application. Root view is a UITableView where user can drill down to a detail UIViewController (call it VC1). User wants to initiate some task but it may require additional info before it can proceed. If so then VC1 allocs & presents modal VC2 using the “flip” transition holding a strong reference to VC2 in a property.

All fairly standard. Here’s where I’m running into trouble. Once user fills out required info in VC2 the app can either continue on to a MFMailComposeViewController or flip back to VC1. If they continue to MailCompose then when that dismisses it should return to VC1.

VC2 has a weak reference to VC1 and the problem arrises when VC2 tries to dismiss itself and present MFMailComposeViewController:

[self dismissModalViewControllerAnimated:YES];  
[VC1 performSelector:@selector(showMailModalView) withObject:nil afterDelay:0.2];

I get a EXC_BAD_ACCESS on VC1 because, apparently, my weak reference to VC1 has already been dealloc’d even though VC1 has strong reference to VC2!?!

So my question is…how should this be handled? Would the delegate pattern be better? How would that be triggered?

Note: VC1 is quite large and VC2 isn’t often needed so I’m trying to keep VC2 as separate as possible from VC1 (including its own NIB).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:19:01+00:00Added an answer on May 14, 2026 at 3:19 am

    VC2 has a weak reference to VC1 and the problem arrises when VC2 tries
    to dismiss itself and present
    MFMailComposeViewController:

    What you have is a circular dependency, since VC1 knows about VC2 and then you let VC2 know about VC1. And When you have circular dependencies, you get all sorts of problems.

    You should be using the delegate pattern here. When VC1 presents VC2, it should make itself VC2’s delegate. When VC2 is done and wants to dismiss itself, it should let the delegate take care of that operation. In other words, the thing that shows VC2 should be the thing that dismisses VC2. VC2 should be implemented in such a way that it shouldn’t know what presented it, only that what presented it will be in charge of dismissing it.

    Two similar answers I’ve given recently:

    Pop-up modal with UITableView on iPhone

    call method in a subclass of UIView

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some advice on what is the best practice to build an online
Starting a new GWT application and wondering if I can get some advice from
I need an advice on best practices for DRYing view code. I have three
Alright, I need some advice and best practices from some Rails people. I'm fairly
I need some advice please on the best way to achieve a particular outcome...
I need some recomendations, best practice/libs, when implementing JSON-RPC in my Spring 3 web
for a data warehouse project I need to know about some best practices regarding
I need some feedback on what is the best way to do what I
Need some quick advice I am trying to access a object array but I
I've got a design decision to make and am looking for some best practice

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.