diff --git a/SwiftCSVExport/Sources/CSVConstants.swift b/SwiftCSVExport/Sources/CSVConstants.swift index ee050de..2cf1d7c 100644 --- a/SwiftCSVExport/Sources/CSVConstants.swift +++ b/SwiftCSVExport/Sources/CSVConstants.swift @@ -106,11 +106,13 @@ extension String { if let string = value as? String { // Wrap around double quotes let doubleQuotes = "'" - - let fString = doubleQuotes+"\(string)"+doubleQuotes - return self.length == 0 ? fString : "\(self)\(div) \(string)" + var fString = doubleQuotes+"\(string)"+doubleQuotes + if (self.count == 0) { + fString = string + } + return self.length == 0 ? fString : "\(self)\(div)\(string)" } else { - return self.length == 0 ? "\(value)" : "\(self)\(div) \(value)" + return self.length == 0 ? "\(value)" : "\(self)\(div)\(value)" } } diff --git a/SwiftCSVExport/Sources/CSVExport.swift b/SwiftCSVExport/Sources/CSVExport.swift index 0e391e1..6766cf4 100644 --- a/SwiftCSVExport/Sources/CSVExport.swift +++ b/SwiftCSVExport/Sources/CSVExport.swift @@ -84,11 +84,11 @@ import Foundation let value = valuesArray[i]; if let lessPrecisePI = Float(value) { - rowsDictionary.setObject(lessPrecisePI, forKey: key as NSCopying); + rowsDictionary.setValue(lessPrecisePI, forKey: key); } else if let morePrecisePI = Double(value) { - rowsDictionary.setObject(morePrecisePI, forKey: key as NSCopying); + rowsDictionary.setValue(morePrecisePI, forKey: key); } else { - rowsDictionary.setObject(value, forKey: key as NSCopying); + rowsDictionary.setValue(value, forKey: key); } } return rowsDictionary;