I'm working on this Objective c programming assignement I found online. I not sure what part C is asking me to do?. I have tried doing a,b and d. Any help or suggestion will be appreciated.
Part 6
a) Implement class A with properties a1, a2, and a3 (int, string, int).
b) New objects are automatically initialized to 1, "hello", 1.
c) Also provide initializer to any data and constructor (called without alloc) to do the same.
d) Make sure %@ ob object of A will print all data.
//ClassA.h file
#import <Foundation/Foundation.h>
@interface ClassA : NSObject
// Part 6a
@property int a1;
@property NSString *a2;
@property int a3;
-(id) initWithA1: (int) x andA2: (NSString *) s andA3: (int) y;
@end
//classA.m file
#import "ClassA.h"
@implementation ClassA
// part 6d
-(NSString *)description {
return [NSString stringWithFormat:@"a1 = %@, a2 = %@ a3 = %@", self.a1, self.a2, self.a3];
}
NSLog (@"%@", self.description);
-(id) initWithA1:(int)x andA2:(NSString *)s andA3:(int)y {
self = [super init];
if (self) {
self.a1 = x;
self.a2 = s;
self.a3 = y;
}
return self;
}
// part 6b
- (id) init {
return [self initWithA1:1 andA2:@"hello" andA3:1];
}
@end