Your return type is void while it should instancetype
.
And you can use both type of code which you want....
Update:
@interface testobj : NSObject
@property (nonatomic,strong) NSDictionary *data;
-(instancetype)initWithDict:(NSDictionary *)dict;
@end
.m
@implementation testobj
@synthesize data;
-(instancetype)initWithDict:(NSDictionary *)dict{
self = [super init];
if(self)
{
self.data = dict;
}
return self;
}
@end
Use it as below:
testobj *tt = [[testobj alloc] initWithDict:@{ @"key": @"value" }];
NSLog(@"%@",tt.ss);