FMResultSet Class Reference

Inherits from NSObject
Declared in FMResultSet.h

Overview

Represents the results of executing a query on an FMDatabase.

See also

Properties

  query

Executed query

@property (atomic, retain) NSString *query

Discussion

Executed query

Declared In

FMResultSet.h

  columnNameToIndexMap

NSMutableDictionary mapping column names to numeric index

@property (readonly) NSMutableDictionary *columnNameToIndexMap

Discussion

NSMutableDictionary mapping column names to numeric index

Declared In

FMResultSet.h

  statement

FMStatement used by result set.

@property (atomic, retain) FMStatement *statement

Discussion

FMStatement used by result set.

Declared In

FMResultSet.h

Creating and closing database

+ resultSetWithStatement:usingParentDatabase:

Create result set from FMStatement

+ (instancetype)resultSetWithStatement:(FMStatement *)statement usingParentDatabase:(FMDatabase *)aDB

Parameters

statement

A FMStatement to be performed

aDB

A FMDatabase to be used

Return Value

A FMResultSet on success; nil on failure

Discussion

Create result set from FMStatement

Declared In

FMResultSet.h

– close

Close result set

- (void)close

Discussion

Close result set

Declared In

FMResultSet.h

Iterating through the result set

– next

Retrieve next row for result set.

- (BOOL)next

Return Value

YES if row successfully retrieved; NO if end of result set reached

Discussion

Retrieve next row for result set.

You must always invoke next or nextWithError before attempting to access the values returned in a query, even if you’re only expecting one.

See Also

Declared In

FMResultSet.h

– nextWithError:

Retrieve next row for result set.

- (BOOL)nextWithError:(NSError **)outErr

Parameters

outErr

A ‘NSError’ object to receive any error object (if any).

Return Value

‘YES’ if row successfully retrieved; ‘NO’ if end of result set reached

Discussion

Retrieve next row for result set.

You must always invoke next or nextWithError before attempting to access the values returned in a query, even if you’re only expecting one.

See Also

Declared In

FMResultSet.h

– hasAnotherRow

Did the last call to next succeed in retrieving another row?

- (BOOL)hasAnotherRow

Return Value

YES if the last call to next succeeded in retrieving another record; NO if not.

Discussion

Did the last call to next succeed in retrieving another row?

Warning: The hasAnotherRow method must follow a call to next. If the previous database interaction was something other than a call to next, then this method may return NO, whether there is another row of data or not.

See Also

Declared In

FMResultSet.h

Retrieving information from result set

– columnCount

How many columns in result set

- (int)columnCount

Return Value

Integer value of the number of columns.

Discussion

How many columns in result set

Declared In

FMResultSet.h

– columnIndexForName:

Column index for column name

- (int)columnIndexForName:(NSString *)columnName

Parameters

columnName

NSString value of the name of the column.

Return Value

Zero-based index for column.

Discussion

Column index for column name

Declared In

FMResultSet.h

– columnNameForIndex:

Column name for column index

- (NSString *)columnNameForIndex:(int)columnIdx

Parameters

columnIdx

Zero-based index for column.

Return Value

columnName NSString value of the name of the column.

Discussion

Column name for column index

Declared In

FMResultSet.h

– intForColumn:

Result set integer value for column.

- (int)intForColumn:(NSString *)columnName

Parameters

columnName

NSString value of the name of the column.

Return Value

int value of the result set’s column.

Discussion

Result set integer value for column.

Declared In

FMResultSet.h

– intForColumnIndex:

Result set integer value for column.

- (int)intForColumnIndex:(int)columnIdx

Parameters

columnIdx

Zero-based index for column.

Return Value

int value of the result set’s column.

Discussion

Result set integer value for column.

Declared In

FMResultSet.h

– longForColumn:

Result set long value for column.

- (long)longForColumn:(NSString *)columnName

Parameters

columnName

NSString value of the name of the column.

Return Value

long value of the result set’s column.

Discussion

Result set long value for column.

Declared In

FMResultSet.h

– longForColumnIndex:

Result set long value for column.

- (long)longForColumnIndex:(int)columnIdx

Parameters

columnIdx

Zero-based index for column.

Return Value

long value of the result set’s column.

Discussion

Result set long value for column.

Declared In

FMResultSet.h

– longLongIntForColumn:

Result set long long int value for column.

- (long long int)longLongIntForColumn:(NSString *)columnName

Parameters

columnName

NSString value of the name of the column.

Return Value

long long int value of the result set’s column.

Discussion

Result set long long int value for column.

Declared In

FMResultSet.h

– longLongIntForColumnIndex:

Result set long long int value for column.

- (long long int)longLongIntForColumnIndex:(int)columnIdx

Parameters

columnIdx

Zero-based index for column.

Return Value

long long int value of the result set’s column.

Discussion

Result set long long int value for column.

Declared In

FMResultSet.h

– unsignedLongLongIntForColumn:

Result set unsigned long long int value for column.

- (unsigned long long int)unsignedLongLongIntForColumn:(NSString *)columnName

Parameters

columnName

NSString value of the name of the column.

Return Value

unsigned long long int value of the result set’s column.

Discussion

Result set unsigned long long int value for column.

Declared In

FMResultSet.h

– unsignedLongLongIntForColumnIndex:

Result set unsigned long long int value for column.

- (unsigned long long int)unsignedLongLongIntForColumnIndex:(int)columnIdx

Parameters

columnIdx

Zero-based index for column.

Return Value

unsigned long long int value of the result set’s column.

Discussion

Result set unsigned long long int value for column.

Declared In

FMResultSet.h

– boolForColumn:

Result set BOOL value for column.

- (BOOL)boolForColumn:(NSString *)columnName

Parameters

columnName

NSString value of the name of the column.

Return Value

BOOL value of the result set’s column.

Discussion

Result set BOOL value for column.

Declared In

FMResultSet.h

– boolForColumnIndex:

Result set BOOL value for column.

- (BOOL)boolForColumnIndex:(int)columnIdx

Parameters

columnIdx

Zero-based index for column.

Return Value

BOOL value of the result set’s column.

Discussion

Result set BOOL value for column.

Declared In

FMResultSet.h

– doubleForColumn:

Result set double value for column.

- (double)doubleForColumn:(NSString *)columnName

Parameters

columnName

NSString value of the name of the column.

Return Value

double value of the result set’s column.

Discussion

Result set double value for column.

Declared In

FMResultSet.h

– doubleForColumnIndex:

Result set double value for column.

- (double)doubleForColumnIndex:(int)columnIdx

Parameters

columnIdx

Zero-based index for column.

Return Value

double value of the result set’s column.

Discussion

Result set double value for column.

Declared In

FMResultSet.h

– stringForColumn:

Result set NSString value for column.

- (NSString *)stringForColumn:(NSString *)columnName

Parameters

columnName

NSString value of the name of the column.

Return Value

NSString value of the result set’s column.

Discussion

Result set NSString value for column.

Declared In

FMResultSet.h

– stringForColumnIndex:

Result set NSString value for column.

- (NSString *)stringForColumnIndex:(int)columnIdx

Parameters

columnIdx

Zero-based index for column.

Return Value

NSString value of the result set’s column.

Discussion

Result set NSString value for column.

Declared In

FMResultSet.h

– dateForColumn:

Result set NSDate value for column.

- (NSDate *)dateForColumn:(NSString *)columnName

Parameters

columnName

NSString value of the name of the column.

Return Value

NSDate value of the result set’s column.

Discussion

Result set NSDate value for column.

Declared In

FMResultSet.h

– dateForColumnIndex:

Result set NSDate value for column.

- (NSDate *)dateForColumnIndex:(int)columnIdx

Parameters

columnIdx

Zero-based index for column.

Return Value

NSDate value of the result set’s column.

Discussion

Result set NSDate value for column.

Declared In

FMResultSet.h

– dataForColumn:

Result set NSData value for column.

- (NSData *)dataForColumn:(NSString *)columnName

Parameters

columnName

NSString value of the name of the column.

Return Value

NSData value of the result set’s column.

Discussion

Result set NSData value for column.

This is useful when storing binary data in table (such as image or the like).

Declared In

FMResultSet.h

– dataForColumnIndex:

Result set NSData value for column.

- (NSData *)dataForColumnIndex:(int)columnIdx

Parameters

columnIdx

Zero-based index for column.

Return Value

NSData value of the result set’s column.

Discussion

Result set NSData value for column.

Declared In

FMResultSet.h

– UTF8StringForColumnName:

Result set (const unsigned char *) value for column.

- (const unsigned char *)UTF8StringForColumnName:(NSString *)columnName

Parameters

columnName

NSString value of the name of the column.

Return Value

(const unsigned char *) value of the result set’s column.

Discussion

Result set (const unsigned char *) value for column.

Declared In

FMResultSet.h

– UTF8StringForColumnIndex:

Result set (const unsigned char *) value for column.

- (const unsigned char *)UTF8StringForColumnIndex:(int)columnIdx

Parameters

columnIdx

Zero-based index for column.

Return Value

(const unsigned char *) value of the result set’s column.

Discussion

Result set (const unsigned char *) value for column.

Declared In

FMResultSet.h

– objectForColumnName:

Result set object for column.

- (id)objectForColumnName:(NSString *)columnName

Parameters

columnName

NSString value of the name of the column.

Return Value

Either NSNumber, NSString, NSData, or NSNull. If the column was NULL, this returns [NSNull null] object.

Discussion

Result set object for column.

Declared In

FMResultSet.h

– objectForColumnIndex:

Result set object for column.

- (id)objectForColumnIndex:(int)columnIdx

Parameters

columnIdx

Zero-based index for column.

Return Value

Either NSNumber, NSString, NSData, or NSNull. If the column was NULL, this returns [NSNull null] object.

Discussion

Result set object for column.

Declared In

FMResultSet.h

– objectForKeyedSubscript:

Result set object for column.

- (id)objectForKeyedSubscript:(NSString *)columnName

Parameters

columnName

NSString value of the name of the column.

Return Value

Either NSNumber, NSString, NSData, or NSNull. If the column was NULL, this returns [NSNull null] object.

Discussion

Result set object for column.

This method allows the use of the “boxed” syntax supported in Modern Objective-C. For example, by defining this method, the following syntax is now supported:

id result = rs[@"employee_name"];

This simplified syntax is equivalent to calling:

id result = [rs objectForKeyedSubscript:@"employee_name"];

which is, it turns out, equivalent to calling:

id result = [rs objectForColumnName:@"employee_name"];

Declared In

FMResultSet.h

– objectAtIndexedSubscript:

Result set object for column.

- (id)objectAtIndexedSubscript:(int)columnIdx

Parameters

columnIdx

Zero-based index for column.

Return Value

Either NSNumber, NSString, NSData, or NSNull. If the column was NULL, this returns [NSNull null] object.

Discussion

Result set object for column.

This method allows the use of the “boxed” syntax supported in Modern Objective-C. For example, by defining this method, the following syntax is now supported:

id result = rs[0];

This simplified syntax is equivalent to calling:

id result = [rs objectForKeyedSubscript:0];

which is, it turns out, equivalent to calling:

id result = [rs objectForColumnName:0];

Declared In

FMResultSet.h

– dataNoCopyForColumn:

Result set NSData value for column.

- (NSData *)dataNoCopyForColumn:(NSString *)columnName

Parameters

columnName

NSString value of the name of the column.

Return Value

NSData value of the result set’s column.

Discussion

Result set NSData value for column.

Warning: If you are going to use this data after you iterate over the next row, or after you close the result set, make sure to make a copy of the data first (or just use dataForColumn:/dataForColumnIndex:) If you don’t, you’re going to be in a world of hurt when you try and use the data.

Declared In

FMResultSet.h

– dataNoCopyForColumnIndex:

Result set NSData value for column.

- (NSData *)dataNoCopyForColumnIndex:(int)columnIdx

Parameters

columnIdx

Zero-based index for column.

Return Value

NSData value of the result set’s column.

Discussion

Result set NSData value for column.

Warning: If you are going to use this data after you iterate over the next row, or after you close the result set, make sure to make a copy of the data first (or just use dataForColumn:/dataForColumnIndex:) If you don’t, you’re going to be in a world of hurt when you try and use the data.

Declared In

FMResultSet.h

– columnIndexIsNull:

Is the column NULL?

- (BOOL)columnIndexIsNull:(int)columnIdx

Parameters

columnIdx

Zero-based index for column.

Return Value

YES if column is NULL; NO if not NULL.

Discussion

Is the column NULL?

Declared In

FMResultSet.h

– columnIsNull:

Is the column NULL?

- (BOOL)columnIsNull:(NSString *)columnName

Parameters

columnName

NSString value of the name of the column.

Return Value

YES if column is NULL; NO if not NULL.

Discussion

Is the column NULL?

Declared In

FMResultSet.h

– resultDictionary

Returns a dictionary of the row results mapped to case sensitive keys of the column names.

- (NSDictionary *)resultDictionary

Return Value

NSDictionary of the row results.

Discussion

Returns a dictionary of the row results mapped to case sensitive keys of the column names.

Warning: The keys to the dictionary are case sensitive of the column names.

Declared In

FMResultSet.h

– resultDict

Returns a dictionary of the row results

- (NSDictionary *)resultDict

Discussion

Returns a dictionary of the row results

Warning: Deprecated: Please use resultDictionary instead. Also, beware that resultDictionary is case sensitive!

Declared In

FMResultSet.h

Key value coding magic

– kvcMagic:

Performs setValue to yield support for key value observing.

- (void)kvcMagic:(id)object

Parameters

object

The object for which the values will be set. This is the key-value-coding compliant object that you might, for example, observe.

Discussion

Performs setValue to yield support for key value observing.

Declared In

FMResultSet.h