0

我有一个名为 Company 的类,我想重写该init方法。我想在此方法中包含公司徽标。我试过这个:

- (id)init
{
self = [super init];
if (self) {
    self.companyName = @"";
    self.companyLogo = nil;
    self.companyDesc = @"";
    self.companyYear = 0;
}
return self;
}

- (id) initWithCompanyName: (NSString*)companyName companyLogo: ***(UIImage*)companyLogo***
 companyDescription: (NSString*)companyDesc foundationYear: (NSInteger)foundationYear
{
self = [self init];
if(self)
{
    self.companyName = companyName;
    self.companyLogo = companyLogo;
    self.companyDesc = companyDesc;
    self.companyYear = foundationYear;
}
return self;
}

显然它不可能是 UIImage。那么我该怎么做才能在初始化中包含图像呢?

4

1 回答 1

2

您使用此调用的类定义工作正常:

UIImage *logo = [UIImage imageNamed:@"IMG_0424.JPG"];
Company *company = [[Company alloc]initWithCompanyName:@"iPichy" companyLogo:logo companyDesc:@"iPichy APP Development" foundationYear:2010];
于 2012-11-06T14:58:45.980 回答