0

can't understand what's wrong in this case, so I cant use the delegate - there is an exception in self.plistManager.delegate = self; Property 'delegate' not found on object of type 'DataPlistManager *'

#import "DataManager.h"
#import "DataPlistManager.h"

@interface DataAdapter : NSObject <DataStorageManager>

@property (nonatomic,strong) DataPlistManager *plistManager;
- (void) saveFile;

@end

and its implementation

#import "DataAdapter.h"

@implementation DataAdapter

-(id) initWithDataPlistManager:(DataPlistManager *) manager
{
    self = [super init];
    self.plistManager = manager;
    self.plistManager.delegate = self;
    return self;
}

- (void) saveFile
{
    [self.plistManager savePlist];
}

@end
ShurupuS
  • 2,923
  • 2
  • 24
  • 44
  • Does `DataPlistManager` declare a `delegate` property? – Sebastian Sep 06 '13 at 05:48
  • In `DataAdapter.h` write reference for the class, using `@class DataPlistManager` before this line `@interface DataAdapter : NSObject ` – Hemang Sep 06 '13 at 05:50
  • 1
    Show the declaration for `DataPlistManager`. – trojanfoe Sep 06 '13 at 05:51
  • Hi, please look on this question http://stackoverflow.com/questions/18636874/cant-call-delegate-method-from-my-protocol-class this is the parent of this question, can't understand how should I set the delegate in this case. Of course there is no property declaration in DataPlistManager because I think that there is no need for this. But the recommendation from the previous answer was to add this line and now there is an exception. – ShurupuS Sep 06 '13 at 06:00

3 Answers3

0

Your DataPlistManager needs a property delegate:

@property (weak) id<DataStorageManager> delegate;
0

If you add #import "DataAdapter.h" in your "DataPlistManager.h" file then remove it and add it to "DataPlistManager.m" file, I don't know but some days ago i have same issue, and i solved it by using this trick :)

iPatel
  • 46,010
  • 16
  • 115
  • 137
0

DataManager class contains delegate property so you should set your object as delegate of DataManager class and call method (send message) saveFile inside delegate class:

@implementation DataAdapter

- (void)someMethod) {
    DataManager *dataManagerObject = [[DataManager alloc] init];
    dataManagerObject.delegate = self;
}

@implementation DataManager

- (void)someDelegateMethod {
    [self.delegate saveFile];
}

Are you sure you understand concept of delegation pattern?

https://developer.apple.com/library/ios/documentation/general/conceptual/CocoaEncyclopedia/DelegatesandDataSources/DelegatesandDataSources.html

GxocT
  • 764
  • 1
  • 10
  • 20