Passer Rating iOS
1.0
iOS demo project for Xcode 4 Unleashed
|
Parser for simple CSV files. More...
#include <SimpleCSVFile.h>
Public Member Functions | |
id | initWithPath: (NSString *aPath) |
Initialize with a path to a CSV file. | |
BOOL | run: (NSError **error) |
Parse the CSV file. | |
Properties | |
NSString * | path |
The path to the CSV file. | |
NSArray * | headers |
An array of NSStrings which are the header names. | |
id< SimpleCSVDelegate > | delegate |
The delegate to which record dictionaries are presented. | |
NSManagedObjectContext * | moc |
A managed-object context, for the use of the client. |
Parser for simple CSV files.
SimpleCSVFile will open a file and attempt to extract key-value data from it. It is expected that the first line will include keys that identify the fields in the data stream.
id initWithPath: | ( | NSString * | aPath | ) | [virtual] |
Initialize with a path to a CSV file.
aPath | A string containing an absolute or relative path to the input file. |
BOOL run: | ( | NSError ** | error | ) | [virtual] |
Parse the CSV file.
Loops through the lines of the input file, interpreting the first line as unique keys for the data fields contained in the remaining lines.
The keys and values for each line are gathered into an NSDictionary, which is presented line-by-line to the delegate object.
It is an error for the file to have a line with a different number of fields than specified in the header line.
[out] | error | A pointer to an NSError object pointer, or nil. If non-nil, and an error occurs (signified by a return value of NO ), *error will describe the problem. |
NO
, and an NSError**
parameter was supplied, *error
will describe the problem.id<SimpleCSVDelegate> delegate [read, write, assign] |
The delegate to which record dictionaries are presented.
NSArray* headers [read, retain] |
An array of NSStrings which are the header names.
NSManagedObjectContext* moc [read, write, assign] |
A managed-object context, for the use of the client.
SimpleCSVFile makes no use of this property. It is provided as a convenience to the caller, so it can associate the records with a managed-object context.
NSString* path [read, write, copy] |
The path to the CSV file.
Setting this property has no effect after run: is called.