簡體   English   中英

&#39;NSMutableSet&#39;不能隱式轉換為&#39;Set <NSObject> &#39;

[英]'NSMutableSet' is not implicitly convertible to 'Set<NSObject>'

我正在使用coreplot在我的應用程序中繪制圖形。 當我嘗試分配X軸標簽或主要刻度位置時,盡管NSMutableSet轉換為NSObject Type的設置,但仍NSMutableSet錯誤。 這是我編寫代碼的方式:

xAxis.axisLabels = xAxisLabels as Set<NSObject>
xAxis.majorTickLocations = xMajorTickLocations as Set<NSObject>

引發的錯誤如下

'NSMutableSet' is not implicitly convertible to 'Set<NSObject>'; did you mean to use 'as' to explicitly convert

盡可能使用本機Swift類型而不是Foundation集合。 這消除了鑄造的需要。

var xAxisLabels = Set<CPTAxisLabel>()
var xMajorTickLocations = Set<NSNumber>()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM