Passer Rating iOS  1.0
iOS demo project for Xcode 4 Unleashed
Public Member Functions | Properties
SimpleCSVFile Class Reference

Parser for simple CSV files. More...

#include <SimpleCSVFile.h>

List of all members.

Public Member Functions

id initWithPath: (NSString *aPath)
 Initialize with a path to a CSV file.
BOOL run: (NSError **error)
 Parse the CSV file.

Properties

NSStringpath
 The path to the CSV file.
NSArray * headers
 An array of NSStrings which are the header names.
id< SimpleCSVDelegatedelegate
 The delegate to which record dictionaries are presented.
NSManagedObjectContext * moc
 A managed-object context, for the use of the client.

Detailed Description

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.

Warning:
This is not a general CSV parser. In particular, it does not handle quotes, embedded commas, or escaping.

Member Function Documentation

id initWithPath: ( NSString aPath) [virtual]

Initialize with a path to a CSV file.

Parameters:
aPathA string containing an absolute or relative path to the input file.
Returns:
The receiver.
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.

Parameters:
[out]errorA 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.
Returns:
Whether parsing succeeded. If NO, and an NSError** parameter was supplied, *error will describe the problem.
See also:
SimpleCSVDelegate

Here is the caller graph for this function:


Property Documentation

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.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Properties Defines