我见过很多代码,其中将ViewModel设置为表视图数据源,而许多代码都没有.
1.将数据源设置到ViewModel一段时间是有意义的,因为数据源方法主要处理表示逻辑.
2.另一方面,将ViewModel设置为数据源意味着您正在实现cellForRowAtIndexPath
等,这使得它不独立于UIKit
.
构建应用程序的最佳方法是什么,请澄清一下?
CGContextRef ctx = CGContextRetain([[NSGraphicsContext currentContext] graphicsPort]);
CGColorRef color = CGColorRetain([NSColor colorWithCalibratedRed:0 green:0 blue:0 alpha:0.5f].CGColor);
CGContextSaveGState(ctx);
{
CGContextSetFillColorWithColor(ctx, color);
CGContextFillRect(ctx, dirtyRect);
}
CGContextRestoreGState(ctx);
CGColorRelease(color);
CGContextRelease(ctx);
Run Code Online (Sandbox Code Playgroud)