Is it possible to narrow the allowed type of an ivar in a subclass. Something like this:
@interface person: NSObject {
NSArray *friendArray;
}
@interface
No, you can't redeclare ivars at all. However, you can make a new method based property without making a new ivar.
@property (nonatomic, copy) NSMutableArray* mutableFriends;
@implementation MutablePerson
- (NSMutableArray*)mutableFriends {
return (NSMutableArray*)friendArray;
}
- (void)setMutableFriends:(NSMutableArray*)friends {
self.friendsArray = [friends mutableCopy];
}
@end