我很难弄清楚如何初始化一个类并将相同的初始化参数传递给多个实例。我可以让它与 1 个插座(instance1)一起工作。但是我怎样才能让它在不为每个实例重写变量的情况下与实例 2 一起工作呢?
视图控制器.h:
#import "CustomClass.h"
@interface MYViewController : UIViewController
@property (unsafe_unretained, nonatomic) IBOutlet CustomClass *instance1;
@property (unsafe_unretained, nonatomic) IBOutlet CustomClass *instance2;
@end
视图控制器.m:
#import "CustomClass.h"
@implementation MYViewController;
@synthesize instance1, instance2;
- (void)viewDidLoad
{
[super viewDidLoad];
instance1.variable1 = option1;
instance1.variable2 = 4.5;
instance1.variable3 = instance1.value;
[instance1 addTarget:self action:@selector(instance1DidChange) forControlEvents:UIControlEventValueChanged];