Inherits from NSObject
Declared in FMResultSet.h

Overview

Represents the results of executing a query on an FMDatabase.

See also

A category that adds support for the encoded data returned by FTS3 functions.

Tasks

Properties

Creating and closing database

Iterating through the result set

Retrieving information from result set

Key value coding magic

  • – kvcMagic:

    Performs setValue to yield support for key value observing.

FTS3 Methods

  • – offsetsForColumnIndex:

    Returns a structure containing values from the offsets() function. Make sure the column index corresponds to the column index in the SQL query.

Properties

columnNameToIndexMap

@property (readonly) NSMutableDictionary *columnNameToIndexMap
Discussion

NSMutableDictionary mapping column names to numeric index

Declared In

FMResultSet.h

query

@property (atomic, retain) NSString *query
Discussion

Executed query

Declared In

FMResultSet.h

statement

@property (atomic, retain) FMStatement *statement
Discussion

FMStatement used by result set.

Declared In

FMResultSet.h

Class Methods

resultSetWithStatement:usingParentDatabase:

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

Create result set from FMStatement

Parameters

statement

A FMStatement to be performed

aDB

A FMDatabase to be used

Return Value

A FMResultSet on success; nil on failure

Declared In

FMResultSet.h

Instance Methods

UTF8StringForColumnIndex:

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

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

Parameters

columnIdx

Zero-based index for column.

Return Value

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

Declared In

FMResultSet.h

UTF8StringForColumnName:

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

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

Parameters

columnName

NSString value of the name of the column.

Return Value

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

Declared In

FMResultSet.h

boolForColumn:

- (BOOL)boolForColumn:(NSString *)columnName
Discussion

Result set BOOL value for column.

Parameters

columnName

NSString value of the name of the column.

Return Value

BOOL value of the result set’s column.

Declared In

FMResultSet.h

boolForColumnIndex:

- (BOOL)boolForColumnIndex:(int)columnIdx
Discussion

Result set BOOL value for column.

Parameters

columnIdx

Zero-based index for column.

Return Value

BOOL value of the result set’s column.

Declared In

FMResultSet.h

close

- (void)close
Discussion

Close result set

Declared In

FMResultSet.h

columnCount

- (int)columnCount
Discussion

How many columns in result set

Return Value

Integer value of the number of columns.

Declared In

FMResultSet.h

columnIndexForName:

- (int)columnIndexForName:(NSString *)columnName
Discussion

Column index for column name

Parameters

columnName

NSString value of the name of the column.

Return Value

Zero-based index for column.

Declared In

FMResultSet.h

columnIndexIsNull:

- (BOOL)columnIndexIsNull:(int)columnIdx
Discussion

Is the column NULL?

Parameters

columnIdx

Zero-based index for column.

Return Value

YES if column is NULL; NO if not NULL.

Declared In

FMResultSet.h

columnIsNull:

- (BOOL)columnIsNull:(NSString *)columnName
Discussion

Is the column NULL?

Parameters

columnName

NSString value of the name of the column.

Return Value

YES if column is NULL; NO if not NULL.

Declared In

FMResultSet.h

columnNameForIndex:

- (NSString *)columnNameForIndex:(int)columnIdx
Discussion

Column name for column index

Parameters

columnIdx

Zero-based index for column.

Return Value

columnName NSString value of the name of the column.

Declared In

FMResultSet.h

dataForColumn:

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

Result set NSData value for column.

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

Parameters

columnName

NSString value of the name of the column.

Return Value

NSData value of the result set’s column.

Declared In

FMResultSet.h

dataForColumnIndex:

- (NSData *)dataForColumnIndex:(int)columnIdx
Discussion

Result set NSData value for column.

Parameters

columnIdx

Zero-based index for column.

Return Value

NSData value of the result set’s column.

Declared In

FMResultSet.h

dataNoCopyForColumn:

- (NSData *)dataNoCopyForColumn:(NSString *)columnName
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.

Parameters

columnName

NSString value of the name of the column.

Return Value

NSData value of the result set’s column.

Declared In

FMResultSet.h

dataNoCopyForColumnIndex:

- (NSData *)dataNoCopyForColumnIndex:(int)columnIdx
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.

Parameters

columnIdx

Zero-based index for column.

Return Value

NSData value of the result set’s column.

Declared In

FMResultSet.h

dateForColumn:

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

Result set NSDate value for column.

Parameters

columnName

NSString value of the name of the column.

Return Value

NSDate value of the result set’s column.

Declared In

FMResultSet.h

dateForColumnIndex:

- (NSDate *)dateForColumnIndex:(int)columnIdx
Discussion

Result set NSDate value for column.

Parameters

columnIdx

Zero-based index for column.

Return Value

NSDate value of the result set’s column.

Declared In

FMResultSet.h

doubleForColumn:

- (double)doubleForColumn:(NSString *)columnName
Discussion

Result set double value for column.

Parameters

columnName

NSString value of the name of the column.

Return Value

double value of the result set’s column.

Declared In

FMResultSet.h

doubleForColumnIndex:

- (double)doubleForColumnIndex:(int)columnIdx
Discussion

Result set double value for column.

Parameters

columnIdx

Zero-based index for column.

Return Value

double value of the result set’s column.

Declared In

FMResultSet.h

hasAnotherRow

- (BOOL)hasAnotherRow
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.

Return Value

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

See Also

Declared In

FMResultSet.h

intForColumn:

- (int)intForColumn:(NSString *)columnName
Discussion

Result set integer value for column.

Parameters

columnName

NSString value of the name of the column.

Return Value

int value of the result set’s column.

Declared In

FMResultSet.h

intForColumnIndex:

- (int)intForColumnIndex:(int)columnIdx
Discussion

Result set integer value for column.

Parameters

columnIdx

Zero-based index for column.

Return Value

int value of the result set’s column.

Declared In

FMResultSet.h

kvcMagic:

- (void)kvcMagic:(id)object
Discussion

Performs setValue to yield support for key value observing.

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.

Declared In

FMResultSet.h

longForColumn:

- (long)longForColumn:(NSString *)columnName
Discussion

Result set long value for column.

Parameters

columnName

NSString value of the name of the column.

Return Value

long value of the result set’s column.

Declared In

FMResultSet.h

longForColumnIndex:

- (long)longForColumnIndex:(int)columnIdx
Discussion

Result set long value for column.

Parameters

columnIdx

Zero-based index for column.

Return Value

long value of the result set’s column.

Declared In

FMResultSet.h

longLongIntForColumn:

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

Result set long long int value for column.

Parameters

columnName

NSString value of the name of the column.

Return Value

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

Declared In

FMResultSet.h

longLongIntForColumnIndex:

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

Result set long long int value for column.

Parameters

columnIdx

Zero-based index for column.

Return Value

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

Declared In

FMResultSet.h

next

- (BOOL)next
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.

Return Value

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

See Also

Declared In

FMResultSet.h

nextWithError:

- (BOOL)nextWithError:(NSError **)outErr
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.

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

See Also

Declared In

FMResultSet.h

objectAtIndexedSubscript:

- (id)objectAtIndexedSubscript:(int)columnIdx
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];

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.

Declared In

FMResultSet.h

objectForColumnIndex:

- (id)objectForColumnIndex:(int)columnIdx
Discussion

Result set object for column.

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.

Declared In

FMResultSet.h

objectForColumnName:

- (id)objectForColumnName:(NSString *)columnName
Discussion

Result set object for column.

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.

Declared In

FMResultSet.h

objectForKeyedSubscript:

- (id)objectForKeyedSubscript:(NSString *)columnName
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"];

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.

Declared In

FMResultSet.h

offsetsForColumnIndex:

- (FMTextOffsets *)offsetsForColumnIndex:(int)columnIdx
Discussion

Returns a structure containing values from the offsets() function. Make sure the column index corresponds to the column index in the SQL query.

Parameters

columnIdx

Zero-based index for column.

Return Value

FMTextOffsets structure.

Declared In

FMDatabase+FTS3.h

resultDict

- (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

resultDictionary

- (NSDictionary *)resultDictionary
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.

Return Value

NSDictionary of the row results.

Declared In

FMResultSet.h

setParentDB:

- (void)setParentDB:(FMDatabase *)newDb

stringForColumn:

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

Result set NSString value for column.

Parameters

columnName

NSString value of the name of the column.

Return Value

NSString value of the result set’s column.

Declared In

FMResultSet.h

stringForColumnIndex:

- (NSString *)stringForColumnIndex:(int)columnIdx
Discussion

Result set NSString value for column.

Parameters

columnIdx

Zero-based index for column.

Return Value

NSString value of the result set’s column.

Declared In

FMResultSet.h

unsignedLongLongIntForColumn:

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

Result set unsigned long long int value for column.

Parameters

columnName

NSString value of the name of the column.

Return Value

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

Declared In

FMResultSet.h

unsignedLongLongIntForColumnIndex:

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

Result set unsigned long long int value for column.

Parameters

columnIdx

Zero-based index for column.

Return Value

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

Declared In

FMResultSet.h