views:

82

answers:

2

Hey,

I have an issue by setting the delegate property for a ViewController which is presented modally. The code below is a modified copy of the example code for Presenting a View Controller Modally.

            AddContactPersonTableViewController *addController = [[AddContactPersonTableViewController alloc] initWithNibName:@"AddContactPersonTableViewController" bundle:nil];
            addController.delegate = self;

            UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:addController];
            [self presentModalViewController:navigationController animated:YES];

            [navigationController release];
            [addController release];

For addController.delegate = self; there is the error: "Request for member 'delegate' in something not a structure or union"

I don't know how to solve this. Maybe you can solve it ;)

A: 

That does your AddContactPersonTableViewController.h look like. Did you add delegate protocol to this class? Do you need to set delegate? You probably dont even need to do it if you dont need the previous viewcontroller to do some action when the new viewcontroller is dismissed or something like that..

Larsaronen
I think, I need this property. After dismissing the ModalViewController the entered data should be stored in an array (instance attribute of previous viewcontroller).
new-iphone-dev
Yeah if so you should use delegate.
Larsaronen
A: 

AddContactPersonTableViewController must have a property declared called delegate in your .h file like:

id delegate;

The delegate should also have a valid setter: @property (nonatomic, retain) id delegate;

Marcus
ohh .. I forgot to declare a property called delegate.
new-iphone-dev