Skip to content

Commit

Permalink
Fixed the strange ordering fields issue.
Browse files Browse the repository at this point in the history
Support [Sring:Any] dictionary type.
  • Loading branch information
vigneshuvi committed May 19, 2017
1 parent 18e2acc commit b87b51c
Show file tree
Hide file tree
Showing 7 changed files with 323 additions and 23 deletions.
16 changes: 16 additions & 0 deletions Sources/CSVExport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,22 @@ public func exportCSV(_ filename:String, fields: [String], values: NSArray) -> S
return CSVExport.export.exportCSV(filename, fields: fields as NSArray, values: values);
}

///a free function to make export the CSV file from file name, fields and values
public func exportCSV(_ filename:String, fields: [String], values: [[String:Any]]) -> String{
// Convert [String:Any] to NSDictionary
let data:NSMutableArray = NSMutableArray()
for dict in values {
let row:NSMutableDictionary = NSMutableDictionary()
for i in 0 ..< fields.count {
row.setValue((dict[fields[i]] != nil ? dict[fields[i]] : ""), forKey: fields[i] );
}
data.add(row)
}

return CSVExport.export.exportCSV(filename, fields: fields as NSArray, values: data);
}


///a free function to make export the CSV file from file name, fields and values
public func exportCSV(_ filename:String, fields: [String], values: String) -> String{

Expand Down
2 changes: 1 addition & 1 deletion SwiftCSVExport.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
#

s.name = "SwiftCSVExport"
s.version = "1.0.1"
s.version = "1.0.2"
s.summary = "Simple way to export csv file with rich feature framework in Swift."

# This description is used to generate tags and improve search results.
Expand Down
22 changes: 8 additions & 14 deletions SwiftCSVExport.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@
objects = {

/* Begin PBXBuildFile section */
0B2F39981E645A4B0019240C /* CSVExport.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B2F39971E645A4B0019240C /* CSVExport.swift */; };
0B54EBD91E4987A00043976B /* SwiftCSVExport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0B54EBCF1E4987A00043976B /* SwiftCSVExport.framework */; };
0B54EBDE1E4987A00043976B /* SwiftCSVExportTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B54EBDD1E4987A00043976B /* SwiftCSVExportTests.swift */; };
0B54EBE01E4987A00043976B /* SwiftCSVExport.h in Headers */ = {isa = PBXBuildFile; fileRef = 0B54EBD21E4987A00043976B /* SwiftCSVExport.h */; settings = {ATTRIBUTES = (Public, ); }; };
0B54EBF91E499C1B0043976B /* SwiftCSVExportOSX.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0B54EBF01E499C1B0043976B /* SwiftCSVExportOSX.framework */; };
0B54EBFE1E499C1B0043976B /* SwiftCSVExportOSXTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B54EBFD1E499C1B0043976B /* SwiftCSVExportOSXTests.swift */; };
0B54EC001E499C1B0043976B /* SwiftCSVExportOSX.h in Headers */ = {isa = PBXBuildFile; fileRef = 0B54EBF21E499C1B0043976B /* SwiftCSVExportOSX.h */; settings = {ATTRIBUTES = (Public, ); }; };
0B65EF4E1E696AFB00ED048A /* CSVExport.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B2F39971E645A4B0019240C /* CSVExport.swift */; };
0B65EF4F1E696AFC00ED048A /* CSVExport.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B2F39971E645A4B0019240C /* CSVExport.swift */; };
0B65EF501E696AFE00ED048A /* CSVExport.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B2F39971E645A4B0019240C /* CSVExport.swift */; };
0B6178681ECF1B1100BCE646 /* CSVExport.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B6178671ECF1B1100BCE646 /* CSVExport.swift */; };
0B69156F1E4DB535007C9394 /* SwiftCSVExport.h in Headers */ = {isa = PBXBuildFile; fileRef = 0B54EBD21E4987A00043976B /* SwiftCSVExport.h */; };
/* End PBXBuildFile section */

Expand All @@ -38,7 +35,6 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
0B2F39971E645A4B0019240C /* CSVExport.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CSVExport.swift; path = Sources/CSVExport.swift; sourceTree = SOURCE_ROOT; };
0B54EBCF1E4987A00043976B /* SwiftCSVExport.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftCSVExport.framework; sourceTree = BUILT_PRODUCTS_DIR; };
0B54EBD21E4987A00043976B /* SwiftCSVExport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SwiftCSVExport.h; sourceTree = "<group>"; };
0B54EBD31E4987A00043976B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand All @@ -51,6 +47,7 @@
0B54EBF81E499C1B0043976B /* SwiftCSVExportOSXTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftCSVExportOSXTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
0B54EBFD1E499C1B0043976B /* SwiftCSVExportOSXTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftCSVExportOSXTests.swift; sourceTree = "<group>"; };
0B54EBFF1E499C1B0043976B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
0B6178671ECF1B1100BCE646 /* CSVExport.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CSVExport.swift; path = Sources/CSVExport.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -90,7 +87,7 @@
0B2F39961E645A410019240C /* Sources */ = {
isa = PBXGroup;
children = (
0B2F39971E645A4B0019240C /* CSVExport.swift */,
0B6178671ECF1B1100BCE646 /* CSVExport.swift */,
);
name = Sources;
sourceTree = "<group>";
Expand Down Expand Up @@ -256,12 +253,12 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0810;
LastUpgradeCheck = 0810;
LastUpgradeCheck = 0830;
ORGANIZATIONNAME = vigneshuvi;
TargetAttributes = {
0B54EBCE1E4987A00043976B = {
CreatedOnToolsVersion = 8.1;
LastSwiftMigration = 0810;
LastSwiftMigration = 0830;
ProvisioningStyle = Manual;
};
0B54EBD71E4987A00043976B = {
Expand Down Expand Up @@ -337,15 +334,14 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0B2F39981E645A4B0019240C /* CSVExport.swift in Sources */,
0B6178681ECF1B1100BCE646 /* CSVExport.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
0B54EBD41E4987A00043976B /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0B65EF4F1E696AFC00ED048A /* CSVExport.swift in Sources */,
0B54EBDE1E4987A00043976B /* SwiftCSVExportTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -354,15 +350,13 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0B65EF4E1E696AFB00ED048A /* CSVExport.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
0B54EBF41E499C1B0043976B /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0B65EF501E696AFE00ED048A /* CSVExport.swift in Sources */,
0B54EBFE1E499C1B0043976B /* SwiftCSVExportOSXTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -401,6 +395,7 @@
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -455,6 +450,7 @@
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -614,7 +610,6 @@
0B54EC051E499C1B0043976B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_IDENTITY = "-";
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = 7FUQA46NH7;
Expand All @@ -632,7 +627,6 @@
0B54EC061E499C1B0043976B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_IDENTITY = "-";
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = 7FUQA46NH7;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "9999"
LastUpgradeVersion = "0830"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0810"
LastUpgradeVersion = "0830"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Loading

0 comments on commit b87b51c

Please sign in to comment.