problem with the custom delegate and the data source

advertisements

I have a custom delegate and datasource. But I have several problems with it when I try to initialize it. In my .h file if have it like this.

@property (nonatomic, assign) id<UITableViewDelegate> delegate;
@property (nonatomic, assign) id<KalDataSource> dataSource;

This has as an result that in the synthesize in the .m file I get the following error.

Existing ivar 'dataSource' for property 'dataSource' with assign attribute must be __unsafe_unretained.

After some google search magic I found that I should assing my variables like this.

@property (nonatomic, strong) id<UITableViewDelegate> delegate;
@property (nonatomic, strong) id<KalDataSource> dataSource;

But then I get this error.

linker command failed with exit code 1 (use -v to see invocation)

Can anybody help me with this?

Kind regards!


Delegates are usually weak references.

The object using the delegate doesn't own it. It's just a reference to an object which could, or could not be responding. Weak says, that if the real owner of the object releases it, it should be deallocated. The weak reference is then automatically set to nil and you don't get any zombies.

Second, the problem is, that you already have property called dataSource.


EDIT

My previous statement about the duplicate property turns out to be wrong. You should override the setters & getters, both the declaration in the .h and the implementation in the .m file.