该块是GridScrollView中定义的一个属性:
typedef BoxView* (^RenderBlock)(NSDictionary* json, CGRect);
@interface GridScrollView : PagingScrollView
@property (nonatomic, copy) RenderBlock renderBlock;
我想像这样使用它:
switch(current.tag)
{
case 1:
scrollView.renderBlock = ^(NSDictionary* json, CGRect frame)
{
//returns a boxview
}
break;
case 2:
scrollView.renderBlock = ^(NSDictionary* json, CGRect frame)
{
//returns a different boxview
}
break;
}
虽然此代码第一次运行良好,但当它被重新分配时,我得到一个 EXC_BAD_ACCESS (code=2, address=0x0) 错误。这里发生了什么事?