ios - What will happen if my class conforms to two protocols having same property? -
let's have 2 protocols
@protocol playlist<nsobject> @property(nonatomic, copy) nsstring *title; @property(nonatomic, assign) nsuinteger trackcount; @end
and as
@protocol album<nsobject> @property(nonatomic, copy) nsstring *name; @property(nonatomic, assign) nsuinteger trackcount; @end
and there class conforms these protocols
.h file
@interface musiclibrary <playlist, album> @end
.m file
@implementation musiclibrary @synthesize title; @synthesize name; @synthesize trackcount; @end
which trackcount property refer to? can use trackcount twice?
it surely not give compile time error.
it looks me modeling data wrong. way have setup musiclibrary both playlist , album. think more correct model have musiclibrary containing many playlist , many albums. like:
@property (nonatomic, strong) nsarray<album>* albums; @property (nonatomic, strong) nsarray<playlist>* playlists;
Comments
Post a Comment