如何在swift中执行块样式功能

如何在swift中执行块样式功能,swift,objective-c-blocks,Swift,Objective C Blocks,我试图在一个Swift应用程序中实现FSLineChart,但由于我在为类设置标签时遇到了故障,所以我被困在了这里 chart.labelForIndex = ^(NSUInteger item) { return [NSString stringWithFormat:@"%lu",(unsigned long)item]; }; chart.labelForValue = ^(CGFloat value) { return [NSString stringWithFormat

我试图在一个Swift应用程序中实现FSLineChart,但由于我在为类设置标签时遇到了故障,所以我被困在了这里

chart.labelForIndex = ^(NSUInteger item) {
    return [NSString stringWithFormat:@"%lu",(unsigned long)item];
};

chart.labelForValue = ^(CGFloat value) {
    return [NSString stringWithFormat:@"%.f", value];
};
我正试图这样解决它

chart.labelForIndex = ({
    (item: UInt) -> String in
    "\(item)"
})
框架在这里


欢迎提供任何帮助

这是我尝试的代码片段。它没有坠毁

let lineChart = FSLineChart(frame: CGRectMake(0, 0, 100, 100))
lineChart.labelForIndex = { index in "label + \(index)" }
也许问题不在于设置闭包?你能把撞车日志贴出来吗