I am very much new to objective-c and I'm struggling with this problem for a while! Here is my class prototype:
@interface YoCatchModel : NSObject
/**
Name of the Yo user. Currently this is local
*/
@property (nonatomic, strong) NSString* username;
/**
History of the messages sent with Yo
*/
@property (nonatomic, strong, readonly) NSMutableArray* historyArray;
/*
implement init method
*/
+ (instancetype) initmethod;
I should allocate memory for my history mutable array in this method which is read only.
I want to make another init method that takes a username string parameter. This new initWithUsername method should call init within its definition.
And here is implementation which I am trying to implement an init method using instancetype as the return type. But I am not really sure how to
- Allocate memory for the array.
Call another init method for the user name.
@implementation YoCatchModel + (instancetype)initmethod { return [[[self class] alloc] init]; }
I appreciate if anyone can give me some hint how to do this. So far I have read these pages to get to here: