Storing protocol/delegation results in the correct Object

I've created a User class with a User object allocated in the first view controller. While in the first view controller, a few of the objects properties are filled with some data. I'm using a second view controller to obtain additional user information and then send it back to the first view controller to store in the remaining object properties. I'm using a protocol and delegation to get this done. I followed the instructions here: Passing Data between View Controllers

Looks like I did everything correctly, except i don't know how to associate the results with the properties of my object. It would be nice to be able to return to the original method in the first view controller that calls the second view controller. Is this possible? A lot of the answers I'm seeing are requiring global variables, but I'm not sure if thats necessary for my case.

/**Implementation of Main View Controller **/

    User * firstUser = [[User alloc] init];

    firstUser.userName = userNameField.text;
    firstUser.password = passwordField.text;

    /**second view controller **/

    SetUp *setUpView = [[SetUp alloc] initWithNibName:Nil bundle:Nil];

    setUpView.delegate = self;

    [self presentViewController:setUpView animated:YES completion:^{ }]; = holdZoneInfo;
    firstUser.area= holdAreaInfo;

    NSLog(@"first User %@, %@, %@, %@",firstUser.userName, firstUser.password,, firstUser.area);

    /**username and password display fine, but zone and area are null since the delegation operation hasn't been completed as this point **/


/**Protocol Method Declared in Main View Controller**/
-(void) sendUserInfoBack: (SetUp *) SetUpController didFinishWithZone:(NSString*)item1 didFinishWithArea:(NSString*) item2

    holdZoneInfo = item1;
    holdAreaInfo = item2;

    NSLog(@"Delegation result: %@ %@", holdZoneInfo, holdAreaInfo);
    /**This displays correctly**/


/**Second view controller implementation file**/

    NSString * neededZoneStore = zoneField.text;
    NSString * neededAreaStore = areaField.text;

    User * user = [[User alloc] init]; = neededZoneStore;
    user.area = neededAreaStore;

    [self.delegate sendUserInfoBack:self didFinishWithZone: neededZoneStore didFinishWithArea: neededAreaStore];

    [self dismissViewControllerAnimated:YES completion:NULL];

So I need = holdZoneInfo but I'm unable to make this happen


In your SetUp view controller class, declare a user property of the type User. When you alloc/init a SetUp view controller set the user property to the firstUser. When the SetUp view controller calls the delegate method, return the firstUser object.

And let the SetUp view controller fill the User object with data from the user.

// in signUpButton
setUpView.user = firstUser;

Refactor the name of the delegate method:

- (void)setUpViewController:(SetUp *)controller exitedWithUser:(User *)user;

Need Your Help

JMeter: How to retrieve Summary Report?

logging report jmeter

After a load test was done in JMeter, it closed due to some reason before I could save the summary report. Is there any way to retrieve the values now?

Getting Error while setting generated id in hibernate

java hibernate id-generation

I have a Student object which i need to save in database. The id : studentId is defined like in HBM :-

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.