I want set NSDate from NSInteger and i have @property:
@property (strong,nonatomic) NSDate *date;
I want setter:
-(void)setDate:(NSInteger *)tStamp {
thumbImgUrl = [NSDate dateWithTimeIntervalSince1970:tStamp];
}
So i want to set my date from NSInteger value not NSDate value. How can i declare this setter? When i try to put it in header file it works ok, but i’m getting a warning:
Type of property 'date' does not match type of accessor 'setDate:
And if i want to declare it in .m file i’m getting error:
duplicate declaration of method setDate:
Why? There is a way to declare setter with different input type?
Generally this is a really bad way of doing things in Objective-C, and I would highly recommend you to change your method name to something else such as
-(void)setDateWithInteger:(NSInteger)tStamp. (Speaking of which, NSInteger is a primitive, not an object) And to answer your question, no, there is no way to declare a setter with different input type if you use@property. If you do insist doing it your way, then you will have to declare the method without using@property.