@@ -41,7 +41,7 @@ class ViewController: UIViewController {
4141 user2. setObject ( " vinoth " , forKey: " name " as NSCopying ) ;
4242 user2. setObject ( false , forKey: " isValidUser " as NSCopying )
4343 user2
. setObject ( " [email protected] " , forKey
: " email " as NSCopying ) ;
44- user2. setObject ( " Hi 'Vinoth!', \n How are you? \t Shall we meet tomorrow? \r Thanks " , forKey: " message " as NSCopying ) ;
44+ user2. setObject ( " Hi 'Vinoth!'; \n How are you? \t Shall we meet tomorrow? \r Thanks " , forKey: " message " as NSCopying ) ;
4545 user2. setObject ( 567.50 , forKey: " balance " as NSCopying ) ;
4646
4747 let data : NSMutableArray = NSMutableArray ( )
@@ -53,7 +53,7 @@ class ViewController: UIViewController {
5353 user3. name = " John "
54545555 user3. isValidUser = true
56- user3. message = " Hi 'John!' \n How are you? \t Shall we meet tomorrow? \r Thanks "
56+ user3. message = " Hi 'John!'; \n How are you? \t Shall we meet tomorrow? \r Thanks "
5757 user3. balance = 105.41 ;
5858 data. add ( listPropertiesWithValues ( user3) ) // Able to convert Class object into NSMutableDictionary
5959
@@ -66,29 +66,36 @@ class ViewController: UIViewController {
6666 writeCSVObj. name = " userlist "
6767
6868 // Write File using CSV class object
69- let filePath : String = SwiftCSVExport . exportCSV ( writeCSVObj) ;
70- print ( filePath)
71-
72-
73- let request = NSURLRequest ( url: URL ( fileURLWithPath: filePath) )
74- webview. loadRequest ( request as URLRequest )
75-
76- //
69+ let result = exportCSV ( writeCSVObj) ;
70+ if result. isSuccess {
71+ guard let filePath = result. value else {
72+ print ( " Export Error: \( String ( describing: result. value) ) " )
73+ return
74+ }
75+
76+ print ( " File Path: \( filePath) " )
77+ self . readCSVPath ( filePath)
78+ } else {
79+ print ( " Export Error: \( String ( describing: result. value) ) " )
80+ }
81+ }
82+
83+ func readCSVPath( _ filePath: String ) {
7784 let fileDetails = readCSV ( filePath) ;
7885 if fileDetails. hasData {
7986 loggly ( LogType . Info, dictionary: fileDetails)
8087 loggly ( LogType . Info, text: fileDetails. name)
8188 loggly ( LogType . Info, text: fileDetails. delimiter)
8289 }
8390
84- // Read File in Object Oriented Way
85- let readCSVObj = readCSVObject ( filePath) ;
86-
91+ let request = NSURLRequest ( url: URL ( fileURLWithPath: filePath) )
92+ webview. loadRequest ( request as URLRequest )
8793
94+ // Read File and convert as CSV class object
95+ let readCSVObj = readCSVObject ( filePath) ;
8896
8997 // Use 'SwiftLoggly' pod framework to print the Dictionary
9098 loggly ( LogType . Info, text: readCSVObj. name)
91-
9299 }
93100
94101 override func didReceiveMemoryWarning( ) {
0 commit comments