有一个正方形类Rectagle,要求实现:定义一个实例初始化方法,初始化方法需要传入边长(整数)和颜色(用字符串表示),以下哪一项符合初始化方法( )
A.
-(id)initWithWidth:(int)width color:(NSString *)color{ if (self){ self.color = color; self.width = width; } return self; }
B.
-(id)initWithWidth:(int)width color:(NSString *)color{ if (self = [super init]) { self.width = width; self.color = color; } return self; }
C.
-(id)createWithWidth:(int)width color:(NSString *)color{ if (self = [super init]) { self.width = width; self.color = color; } return self; }
D.
-(id)initWithName:(NSString *)name sex:(NSString *)sex{ if (self = [super init]) { self.width = width; self.color = color; } }