下面咱们还是通过代码来说明这个结构图。
实例
建造者模式的代码
Product.m(部分代码):
复制代码- (id)init
{
self = [superinit];
if (self)
{
arrParts = [NSMutableArrayarray];
}
returnself;
}
- (void)addPart:(NSString *)part
{
[arrPartsaddObject:part];
}
- (void)show
{
for (NSString *strPart inarrParts)
{
NSLog(@"%@",strPart);
}
}
Builder.h(部分代码):
复制代码
@classProduct;
@protocol Builder <NSObject>
- (void)addPartOne;










