pdenlinger
pdenlinger

Reputation: 3917

Implementation file can't see protocol delegate

Have declared a protocol in a header file, but the implementation file says that it can't see the delegate. Why?

The Xcode compiler message is commented out in the implementation file.

Thanks in advance.

AddItemViewController.h

#import <UIKit/UIKit.h>

@class AddItemViewController;
@class ChecklistItem;

@protocol AddItemViewControllerDelegate <NSObject>

- (void)addItemViewControllerDidCancel:(AddItemViewController *)controller;
- (void)addItemViewController:(AddItemViewController *)controller didFinishAddingItem:(ChecklistItem *)item;

@property (nonatomic, weak) id <AddItemViewControllerDelegate> delegate;

@end

@interface AddItemViewController : UITableViewController <UITextFieldDelegate>

@property (weak, nonatomic) IBOutlet UITextField *textField;
@property (weak, nonatomic) IBOutlet UIBarButtonItem *doneBarButton;

- (IBAction)cancel;
- (IBAction)done;

@end

AddItemViewController.m

- (IBAction)cancel
{
    [self.delegate addItemViewControllerDidCancel:self]; /* Semantic issue: Property 'delegate' not found on object of  type     "AddItemViewController" */
}

- (IBAction)done
{
    ChecklistItem *item = [[ChecklistItem alloc] init];
    item.text = self.textField.text;
    item.checked = NO;

    [self.delegate AddItemViewController:self didFinishAddingItem:item]; /* Semantic issue: Property 'delegate' not found on object of  type     "AddItemViewController" */

}

Upvotes: 0

Views: 69

Answers (1)

Daij-Djan
Daij-Djan

Reputation: 50089

aeh .. is that a typo? the delegate property is defined on the delegate protocol. of course the VC class can't see it ;)

Upvotes: 3

Related Questions