瀏覽代碼

Added @discardableResult to silence warnings when it’s safe to ignore result

Daniel Cohen Gindi 8 年之前
父節點
當前提交
17ffa28011

+ 5 - 5
Source/Charts/Data/Implementations/ChartBaseDataSet.swift

@@ -126,12 +126,12 @@ open class ChartBaseDataSet: NSObject, IChartDataSet
         fatalError("addEntryOrdered is not implemented in ChartBaseDataSet")
         fatalError("addEntryOrdered is not implemented in ChartBaseDataSet")
     }
     }
     
     
-    open func removeEntry(_ entry: ChartDataEntry) -> Bool
+    @discardableResult open func removeEntry(_ entry: ChartDataEntry) -> Bool
     {
     {
         fatalError("removeEntry is not implemented in ChartBaseDataSet")
         fatalError("removeEntry is not implemented in ChartBaseDataSet")
     }
     }
     
     
-    open func removeEntry(index: Int) -> Bool
+    @discardableResult open func removeEntry(index: Int) -> Bool
     {
     {
         if let entry = entryForIndex(index)
         if let entry = entryForIndex(index)
         {
         {
@@ -140,7 +140,7 @@ open class ChartBaseDataSet: NSObject, IChartDataSet
         return false
         return false
     }
     }
     
     
-    open func removeEntry(x: Double) -> Bool
+    @discardableResult open func removeEntry(x: Double) -> Bool
     {
     {
         if let entry = entryForXValue(x, closestToY: Double.nan)
         if let entry = entryForXValue(x, closestToY: Double.nan)
         {
         {
@@ -149,7 +149,7 @@ open class ChartBaseDataSet: NSObject, IChartDataSet
         return false
         return false
     }
     }
     
     
-    open func removeFirst() -> Bool
+    @discardableResult open func removeFirst() -> Bool
     {
     {
         if entryCount > 0
         if entryCount > 0
         {
         {
@@ -161,7 +161,7 @@ open class ChartBaseDataSet: NSObject, IChartDataSet
         return false
         return false
     }
     }
     
     
-    open func removeLast() -> Bool
+    @discardableResult open func removeLast() -> Bool
     {
     {
         if entryCount > 0
         if entryCount > 0
         {
         {

+ 4 - 4
Source/Charts/Data/Implementations/Standard/ChartData.swift

@@ -454,7 +454,7 @@ open class ChartData: NSObject
     /// Also recalculates all minimum and maximum values.
     /// Also recalculates all minimum and maximum values.
     ///
     ///
     /// - returns: `true` if a DataSet was removed, `false` ifno DataSet could be removed.
     /// - returns: `true` if a DataSet was removed, `false` ifno DataSet could be removed.
-    open func removeDataSet(_ dataSet: IChartDataSet!) -> Bool
+    @discardableResult open func removeDataSet(_ dataSet: IChartDataSet!) -> Bool
     {
     {
         if dataSet === nil
         if dataSet === nil
         {
         {
@@ -476,7 +476,7 @@ open class ChartData: NSObject
     /// Also recalculates all minimum and maximum values. 
     /// Also recalculates all minimum and maximum values. 
     ///
     ///
     /// - returns: `true` if a DataSet was removed, `false` ifno DataSet could be removed.
     /// - returns: `true` if a DataSet was removed, `false` ifno DataSet could be removed.
-    open func removeDataSetByIndex(_ index: Int) -> Bool
+    @discardableResult open func removeDataSetByIndex(_ index: Int) -> Bool
     {
     {
         if index >= _dataSets.count || index < 0
         if index >= _dataSets.count || index < 0
         {
         {
@@ -508,7 +508,7 @@ open class ChartData: NSObject
     }
     }
     
     
     /// Removes the given Entry object from the DataSet at the specified index.
     /// Removes the given Entry object from the DataSet at the specified index.
-    open func removeEntry(_ entry: ChartDataEntry, dataSetIndex: Int) -> Bool
+    @discardableResult open func removeEntry(_ entry: ChartDataEntry, dataSetIndex: Int) -> Bool
     {
     {
         // entry outofbounds
         // entry outofbounds
         if dataSetIndex >= _dataSets.count
         if dataSetIndex >= _dataSets.count
@@ -530,7 +530,7 @@ open class ChartData: NSObject
     /// Removes the Entry object closest to the given xIndex from the ChartDataSet at the
     /// Removes the Entry object closest to the given xIndex from the ChartDataSet at the
     /// specified index. 
     /// specified index. 
     /// - returns: `true` if an entry was removed, `false` ifno Entry was found that meets the specified requirements.
     /// - returns: `true` if an entry was removed, `false` ifno Entry was found that meets the specified requirements.
-    open func removeEntry(xValue: Double, dataSetIndex: Int) -> Bool
+    @discardableResult open func removeEntry(xValue: Double, dataSetIndex: Int) -> Bool
     {
     {
         if dataSetIndex >= _dataSets.count
         if dataSetIndex >= _dataSets.count
         {
         {