Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Base class
- @interface BaseClass : NSObject
- @property(nonatomic,strong)NSString *name;
- @end
- @implementation ClassObject
- @synthesize name;
- @end
- // Derived1 -class from BaseClass
- @interface Derived1 : BaseClass
- @end
- @implementation classA
- @end
- //Derived2 -class from BaseClass
- @interface Derived2 : BaseClass
- @property(nonatomic,strong)NSString *age;
- @end
- @implementation classB
- @synthesize age;
- @end
- int main(int argc, char * argv[])
- {
- @autoreleasepool {
- BaseClass *instanceOfDerived1=[[Derived1 alloc]init];
- BaseClass *instaceOfDerived2=[[Derived2 alloc]init];
- instanceOfDerived1.name=@"Welcome";
- instanceOfDerived2.age=23; // Here This property is not there in Baseclass, So Here we can't able use the Setter mechanism here for setting the Age' value, But we can able to use the Name' property.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement