目标 c - 不允许将"只读"填充分配给属性



我正在做AQGridView的实现,一切都很顺利。

但是,现在我得到了下面的错误。

- (AQGridViewCell *) gridView: (AQGridView *)inGridView cellForItemAtIndex: (NSUInteger) index;
  {
MagazineCell *cell = (MagazineCell *)[inGridView dequeueReusableCellWithIdentifier:@"cell"];
if (!cell) {
    cell = [MagazineCell cell];
    cell.reuseIdentifier = @"cell";
            //Assigning to property with 'readonly' atribute not allowed
}
cell.backgroundColor = [UIColor clearColor];
cell.selectionStyle = AQGridViewCellSelectionStyleGlow;

cell.edicaoLabel.text = [[edicoesArray objectAtIndex:index] name];
    cell.dataLabel.text = [[edicoesArray objectAtIndex:index] name];
return cell;
}

我试着在头文件上做这件事

@property(nonatomic, readwrite) NSString * reuseIdentifier;

我也试过

@property(nonatomic, assign) NSString * reuseIdentifier;

但仍然没有工作。

我下载了项目"Actors for Netflix"的示例https://github.com/adrianco/Actors-for-Netflix-on-iPad/

当我尝试构建时,这段代码也有同样的问题,预处理器也看到了

这个例子没有在类文件的头上声明属性,我在我的项目中尝试了它,试图解决这个问题。

有人可以看到问题出在哪里?

谢谢!

代码被设计为只读,正如ActorCell从其继承的AQGridViewCell内部所见。仅仅因为它在GitHub上并不意味着它可以工作。reuseIdentifier应该传递到UITableViewCell s的初始值设定项中。下面是一个示例。

//MagazineCellCode
+(MagazineCell*)cellWithReuseIdentifier:(NSString*)identifier
{
    MagazineCell *cell = [[[MagazineCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier] autorelease];
    //Any custom configuration here
    return cell;
}
//TableView Code
if (!cell) {
    cell = [MagazineCell cellWithReuseIdentifier:@"cell"];
}

我想你想要@property(nonatomic, retain),但我不能100%确定。我认为你所拥有的一切都应该奏效——你尝试过全新的翻拍吗?什么版本的Xcode?

最新更新