There is a general class Animal and descendants (three more classes) that contain the name, age, color of the animal. There is also a forward button when you click on which information should change. Does anyone know how this can be done. Animal class:
#import <Foundation/Foundation.h> @interface OMAnimal : NSObject @property (copy, nonatomic) NSString *name; @property (copy, nonatomic) NSString *color; @property (assign, nonatomic) NSInteger age; @end Display:
#import "OMAnimalViewController.h" #import "OMCat.h" #import "OMDog.h" #import "OMMonkey.h" @interface OMAnimalViewController () @property (assign, nonatomic) NSInteger index; @property (strong, nonatomic) NSArray *arrayAnimal; @end @implementation OMAnimalViewController - (void)viewDidLoad { [super viewDidLoad]; OMCat *animalCat = [[OMCat alloc] init]; animalCat.name = @"Kate"; animalCat.age = 6; animalCat.color = @"White"; OMDog *animalDog = [[OMDog alloc] init]; animalDog.name = @"Bob"; animalDog.age = 3; animalDog.color = @"Balck"; OMMonkey *animalMonkey = [[OMMonkey alloc] init]; animalMonkey.name = @"Charly"; animalMonkey.age = 7; animalMonkey.color = @"Brown"; _arrayAnimal = @[animalCat, animalDog, animalMonkey]; [self updateAnimal]; } - (void)updateAnimal { OMCat *cat = _arrayAnimal[0]; self.nameLabel.text = cat.name; self.ageLabel.text = [NSString stringWithFormat:@"%d", cat.age]; self.colorLabel.text = cat.color; } - (IBAction)actionNext:(UIButton *)sender { } @end