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 9067809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:02:07+00:00 2026-06-16T17:02:07+00:00

I am implementing a custom URL scheme which will add entities to my data

  • 0

I am implementing a custom URL scheme which will add entities to my data model. The details for the entity are contained in the URL. The basic idea is that an email link (or a link from another app) will open my app and add the new entity.

The problem is, I can never be sure which state my app will be in when responding. Any number of view controllers might be in view. If the list of entities is in view, I need to insert a new row for that entity. If other views are on screen, I need to react differently. Some views might also be modal.

I would be satisfied with a simple pattern when this happens – abort whatever the user is currently doing, and pop to the root view controller. From here I will probably push to a controller where I will show the new entity being added.

I experimented with always dismissing any modal displayed and popping to the root, with the benefit of not needing to know what exactly is being displayed:

[(UINavigationController *)self.window.rootViewController dismissViewControllerAnimated:NO completion:nil];
[(UINavigationController *)self.window.rootViewController popToRootViewControllerAnimated:NO];

This works reasonably well, but there at least two cases where it is insufficient:

  1. If some object was created when the modal was presented (the modal is then used to modify the new object), and it is the delegate’s responsibility to delete the object if the user cancels, the entity will remain alive.
  2. If a UIActionSheet is being displayed, all bets are off. I can’t dismiss this without knowing the controller that displayed it, having access to that controller, and sending it a message to dismiss the action sheet. Without doing so, the root view controller is popped to but the action sheet stays on screen. Subsequent taps on the action sheet of course cause a crash, since the controller that displayed it is gone.

How might I handle this robustly? Should I be trying to find out specifically which view controller is currently presented, and handling each scenario in turn? Or is there a more scalable solution that won’t need updating each time I add controllers or change my application’s flow?

  • 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-06-16T17:02:08+00:00Added an answer on June 16, 2026 at 5:02 pm

    It sounds like you are trying to do several things:

    1. When the user clicks on your custom url, you want to add an “entity” to your model.
    2. You want to display this new entity in some sort of EntityListViewController, which may or may not be on the ViewController stack.
    3. You (may) want to pop off all view controllers above the EntityListViewController.
    4. You want the user to know there was a new entity added (perhaps just by doing item 2).
    5. You want to push some kind of EntityViewController, or if there is currently an EntityViewController in the view controller stack, you want to reload with the new entity’s data.

    It sounds like you have item 1 ready to go, since you didn’t explicitly ask about handling the url click and inserting the new model object.

    For the rest, a flexible and MVC-ish pattern would be to use NSNotificationCenter.

    The code that inserts the new model object would “post” a notification:

    [[NSNotifcationCenter defaultCenter] postNotificationName:@"entity_added" object:myNewEntity];
    

    Then your various UI elements (e.g., UIAlertView and UIViewController subclasses) would listen for this notification and take some useful action (like closing themselves, or in the case of EntityListViewController or EntityViewController, reloading themselves).

    For example, a UIViewController subclass might do this:

    -(void) viewDidLoad
    {
      [super viewDidLoad];
      [[NSNoticationCenter defaultCenter] addObserver:self selector:@selector(onNewEntity:) name:@"entity_added" object:nil];
    
    
    -(void) onNewEntity:(MyEntity*)entity
    {
       // close, or redraw or...
    }
    
    -(void) dealloc
    {
      [[NSNoticationCenter defaultCenter] removeObserver:self];
      // if not using ARC, also call [super dealloc];
    }
    

    To keep your life simple (and not worry too much about all the different UI states), I would consider doing this when the notification occurs:

    1. Have the EntityListViewController redraw itself (does not matter if there something on top of it).
    2. Show some sort of short-lived indicator in the nav bar (or somewhere else you know is always visible), or play a sound so the user knows that an entity was added.
    3. And that’s all.

    If you take this approach, then there is minimal impact on whatever the user is/was doing, but when they do navigate back to the EntityListViewController it has all the new entities already displayed.

    Clearly, if the click on the custom URL could possibly delete an existing entity, then it would be more important to pop off any viewcontrollers related to that entity. But this is also something you could do using the same pattern — have the model or controller post the notification, and then have the various UI elements listen for it and take appropriate action.

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

Sidebar

Related Questions

I'm implementing a custom BCS Model to get data from a backend system. As
I'm implementing a custom URL scheme in my navigation based app to let users
I'm implementing a custom URL scheme for one of my apps and can't get
I am implementing a custom MembershipProvider in order to pass the login details to
I'm having a small issue with implementing custom basic authentication for a asmx in
I'm using ASP.NET MVC and implementing custom validation via custom attributes/data annotations on my
I have a Telerik RadGrid in which I'm implementing custom paging binding to a
I'm looking for some pointers on implementing Custom Events in VB.NET (Visual Studio 2008,
Implementing a custom Dependency Property on a Framework Element object causes my Visual Studio
Implementing a custom membership provider, there are certain properties such as MinRequiredPasswordLength that only

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.