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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:40:33+00:00 2026-05-25T02:40:33+00:00

So I have two views A and B. A is a profile view, B

  • 0

So I have two views A and B. A is a profile view, B is a login view. A loads B in the ViewDidLoad Method using

LoginViewController *lvc = [[LoginViewController alloc]initWithNibName:@"LoginViewController" bundle:[NSBundle mainBundle]]; //make new instance of LoginViewController
        [self presentModalViewController:lvc animated:NO]; //present the LoginViewController
        [lvc release];

in the login View, if the login is successful, the view is removed

[self dismissModalViewControllerAnimated:YES];

On the login view, It downloads some data which I want to display on the profile view. How would I go about sending the data to the profile view and displaying it in the xib. I believe the profile view is already displayed but is just hidden.

  • 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-25T02:40:34+00:00Added an answer on May 25, 2026 at 2:40 am

    This is a basic “communicate between two classes” question. There are many ways to do this, but here are three. I only wrote sample code for delegation (because I think that’s probably the best choice in your situation), but let me know if you want examples of notifications or KVO.

    Delegation Implement a delegation or callback method in Class A. Delegation is best for small class hierarchies. If Class A is the only class that will load B and A is the only class who cares what happens in B, then delegation is the easiest way to move data around. It’s simple to implement, it’s simple to understand and there’s a clear relationship between the classes.

    // Class A
    - (void)displayLoginViewController {
        LoginViewController *lvc = [[LoginViewController alloc]initWithNibName:@"LoginViewController" bundle:[NSBundle mainBundle]];
        lvc.delegate = self;
        [self presentModalViewController:lvc animated:NO]; //present the LoginViewController
        [lvc release];
    }
    
    - (void)loginViewControllerWasSuccessfull:(LoginViewController *)loginViewController {
        // Do whatever you need to do here
        [self dismissModalViewControllerAnimated:YES];
    
    }
    

    In the login view controller do something like this in the header:

    @property (assign) NSObject delegate; // declared assign so you don't have circular references
    

    … and this in the implementation:

    - (void)didLogin {
        [self.delegate loginViewControllerWasSuccessfull:self];
    }
    

    Notification Class A will register to listen for login notifications. Class B will post login notifications. Notifications are best if the classes that care about login are distributed. i.e. there are many classes that care about a login event and they may not necessarily have a direct relationship with the class that is performing the login.

    Key Value Observing KVO is best if you don’t particularly care about the login event, you care about the changes to the data. You will have some class that manages your data, probably an NSManagedObject if you are using Core Data. Class A will observe changes to whatever property it’s interested in. Your LoginViewController will update that data class when it is finished downloading data. Class A will be notified that the data has changed.

    Whatever solution you decide to use, the choice ultimately comes down to asking, “What does Class A care about?”. Does Class A need to know that Class B successfully logged in? Use delegation. Does Class A need to know that somewhere, some class logged in? Use notifications. Does Class A not care about logins, it only needs to know if data has changed? Use KVO.

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

Sidebar

Related Questions

I have two views, one view takes the whole screen, the second view covers
I have two views within one .xib (one view for landscape, another for portrait).
I have an app that has a centre view with two views off to
I have two forms in one view updating the User Profile. One Form is
If I have two views, is it possible to create in a view a
I have a two views, 1st is a simple view with some introduction about
I have two views (UIView) set-up: parent and child view. The child view is
I have two views, a game view and an admob view. I want the
I have two views that I would like to combine into one. The first
I have a repositories, i want to have two views: Developers can see the

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.