我已将“接口”构建器中的NSTextView
放入我的故事板文件中。我将stringValue
设置为从API端点返回的漂亮的JSON字符串。设置字符串后,包含NSTextView
(Apple默认在IB中添加)的滚动视图无法获得正确的内容大小,因此您无法滚动查看整个内容。
selectedEndpoint.refreshHandler({ [weak self] (result) in
guard let strongSelf = self else { return }
switch result {
case .success(let responseString):
strongSelf.responses[strongSelf.selectedTab] = responseString
OperationQueue.main.addOperation {
strongSelf.responseTextView.string = responseString
strongSelf.responseTextView.needsLayout = true
}
break
case .failure(_):
OperationQueue.main.addOperation {
strongSelf.responseTextView.string = ""
strongSelf.responseTextView.needsLayout = true
}
break
}
})
参见附页截图: