AWSFMResultSet

Objective-C

@interface AWSFMResultSet : NSObject {
  AWSFMDatabase *_parentDB;
  AWSFMStatement *_statement;
  NSString *_query;
  NSMutableDictionary *_columnNameToIndexMap;
}

Swift

class AWSFMResultSet : NSObject

Represents the results of executing a query on an <FMDatabase>.

### See also

  • <FMDatabase>

Properties

  • Executed query

    Declaration

    Objective-C

    @property (retain) NSString *query;

    Swift

    var query: String! { get set }
  • NSMutableDictionary mapping column names to numeric index

    Declaration

    Objective-C

    @property (readonly) NSMutableDictionary *columnNameToIndexMap;

    Swift

    var columnNameToIndexMap: NSMutableDictionary! { get }
  • FMStatement used by result set.

    Declaration

    Objective-C

    @property (retain) AWSFMStatement *statement;

    Swift

    var statement: AWSFMStatement! { get set }

Creating and closing database

Iterating through the result set

  • 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

    hasAnotherRow

    Declaration

    Objective-C

    - (BOOL)next;

    Swift

    func next() -> Bool

    Return Value

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

  • 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

    hasAnotherRow

    Declaration

    Objective-C

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

    Swift

    func nextWithError() throws

    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

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

    See

    next

    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.

    Declaration

    Objective-C

    - (BOOL)hasAnotherRow;

    Swift

    func hasAnotherRow() -> Bool

    Return Value

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

Retrieving information from result set

  • How many columns in result set

    Declaration

    Objective-C

    - (int)columnCount;

    Swift

    func columnCount() -> Int32

    Return Value

    Integer value of the number of columns.

  • Column index for column name

    Declaration

    Objective-C

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

    Swift

    func columnIndex(forName columnName: String!) -> Int32

    Parameters

    columnName

    NSString value of the name of the column.

    Return Value

    Zero-based index for column.

  • Column name for column index

    Declaration

    Objective-C

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

    Swift

    func columnName(for columnIdx: Int32) -> String!

    Parameters

    columnIdx

    Zero-based index for column.

    Return Value

    columnName NSString value of the name of the column.

  • Result set integer value for column.

    Declaration

    Objective-C

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

    Swift

    func int(forColumn columnName: String!) -> Int32

    Parameters

    columnName

    NSString value of the name of the column.

    Return Value

    int value of the result set’s column.

  • Result set integer value for column.

    Declaration

    Objective-C

    - (int)intForColumnIndex:(int)columnIdx;

    Swift

    func int(forColumnIndex columnIdx: Int32) -> Int32

    Parameters

    columnIdx

    Zero-based index for column.

    Return Value

    int value of the result set’s column.

  • Result set long value for column.

    Declaration

    Objective-C

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

    Swift

    func long(forColumn columnName: String!) -> Int

    Parameters

    columnName

    NSString value of the name of the column.

    Return Value

    long value of the result set’s column.

  • Result set long value for column.

    Declaration

    Objective-C

    - (long)longForColumnIndex:(int)columnIdx;

    Swift

    func long(forColumnIndex columnIdx: Int32) -> Int

    Parameters

    columnIdx

    Zero-based index for column.

    Return Value

    long value of the result set’s column.

  • Result set long long int value for column.

    Declaration

    Objective-C

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

    Swift

    func longLongInt(forColumn columnName: String!) -> Int64

    Parameters

    columnName

    NSString value of the name of the column.

    Return Value

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

  • Result set long long int value for column.

    Declaration

    Objective-C

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

    Swift

    func longLongInt(forColumnIndex columnIdx: Int32) -> Int64

    Parameters

    columnIdx

    Zero-based index for column.

    Return Value

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

  • Result set unsigned long long int value for column.

    Declaration

    Objective-C

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

    Swift

    func unsignedLongLongInt(forColumn columnName: String!) -> UInt64

    Parameters

    columnName

    NSString value of the name of the column.

    Return Value

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

  • Result set unsigned long long int value for column.

    Declaration

    Objective-C

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

    Swift

    func unsignedLongLongInt(forColumnIndex columnIdx: Int32) -> UInt64

    Parameters

    columnIdx

    Zero-based index for column.

    Return Value

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

  • Result set BOOL value for column.

    Declaration

    Objective-C

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

    Swift

    func bool(forColumn columnName: String!) -> Bool

    Parameters

    columnName

    NSString value of the name of the column.

    Return Value

    BOOL value of the result set’s column.

  • Result set BOOL value for column.

    Declaration

    Objective-C

    - (BOOL)boolForColumnIndex:(int)columnIdx;

    Swift

    func bool(forColumnIndex columnIdx: Int32) -> Bool

    Parameters

    columnIdx

    Zero-based index for column.

    Return Value

    BOOL value of the result set’s column.

  • Result set double value for column.

    Declaration

    Objective-C

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

    Swift

    func double(forColumn columnName: String!) -> Double

    Parameters

    columnName

    NSString value of the name of the column.

    Return Value

    double value of the result set’s column.

  • Result set double value for column.

    Declaration

    Objective-C

    - (double)doubleForColumnIndex:(int)columnIdx;

    Swift

    func double(forColumnIndex columnIdx: Int32) -> Double

    Parameters

    columnIdx

    Zero-based index for column.

    Return Value

    double value of the result set’s column.

  • Result set NSString value for column.

    Declaration

    Objective-C

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

    Swift

    func string(forColumn columnName: String!) -> String!

    Parameters

    columnName

    NSString value of the name of the column.

    Return Value

    NSString value of the result set’s column.

  • Result set NSString value for column.

    Declaration

    Objective-C

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

    Swift

    func string(forColumnIndex columnIdx: Int32) -> String!

    Parameters

    columnIdx

    Zero-based index for column.

    Return Value

    NSString value of the result set’s column.

  • Result set NSDate value for column.

    Declaration

    Objective-C

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

    Swift

    func date(forColumn columnName: String!) -> Date!

    Parameters

    columnName

    NSString value of the name of the column.

    Return Value

    NSDate value of the result set’s column.

  • Result set NSDate value for column.

    Declaration

    Objective-C

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

    Swift

    func date(forColumnIndex columnIdx: Int32) -> Date!

    Parameters

    columnIdx

    Zero-based index for column.

    Return Value

    NSDate value of the result set’s column.

  • Result set NSData value for column.

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

    Declaration

    Objective-C

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

    Swift

    func data(forColumn columnName: String!) -> Data!

    Parameters

    columnName

    NSString value of the name of the column.

    Return Value

    NSData value of the result set’s column.

  • Result set NSData value for column.

    Declaration

    Objective-C

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

    Swift

    func data(forColumnIndex columnIdx: Int32) -> Data!

    Parameters

    columnIdx

    Zero-based index for column.

    Return Value

    NSData value of the result set’s column.

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

    Declaration

    Objective-C

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

    Swift

    func utf8String(forColumnName columnName: String!) -> UnsafePointer<UInt8>!

    Parameters

    columnName

    NSString value of the name of the column.

    Return Value

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

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

    Declaration

    Objective-C

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

    Swift

    func utf8String(forColumnIndex columnIdx: Int32) -> UnsafePointer<UInt8>!

    Parameters

    columnIdx

    Zero-based index for column.

    Return Value

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

  • Result set object for column.

    See

    objectForKeyedSubscript:

    Declaration

    Objective-C

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

    Swift

    func object(forColumnName columnName: String!) -> Any!

    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.

  • Result set object for column.

    See

    objectAtIndexedSubscript:

    Declaration

    Objective-C

    - (id)objectForColumnIndex:(int)columnIdx;

    Swift

    func object(forColumnIndex columnIdx: Int32) -> Any!

    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.

  • 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"];
    

    Declaration

    Objective-C

    - (id)objectForKeyedSubscript:(NSString *)columnName;

    Swift

    subscript(columnName: String!) -> Any! { get }

    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.

  • 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];
    

    Declaration

    Objective-C

    - (id)objectAtIndexedSubscript:(int)columnIdx;

    Swift

    subscript(columnIdx: Int32) -> Any! { get }

    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.

  • 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.

    Declaration

    Objective-C

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

    Swift

    func dataNoCopy(forColumn columnName: String!) -> Data!

    Parameters

    columnName

    NSString value of the name of the column.

    Return Value

    NSData value of the result set’s column.

  • 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.

    Declaration

    Objective-C

    - (NSData *)dataNoCopyForColumnIndex:(int)columnIdx;

    Swift

    func dataNoCopy(forColumnIndex columnIdx: Int32) -> Data!

    Parameters

    columnIdx

    Zero-based index for column.

    Return Value

    NSData value of the result set’s column.

  • Is the column NULL?

    Declaration

    Objective-C

    - (BOOL)columnIndexIsNull:(int)columnIdx;

    Swift

    func columnIndexIsNull(_ columnIdx: Int32) -> Bool

    Parameters

    columnIdx

    Zero-based index for column.

    Return Value

    YES if column is NULL; NO if not NULL.

  • Is the column NULL?

    Declaration

    Objective-C

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

    Swift

    func columnIsNull(_ columnName: String!) -> Bool

    Parameters

    columnName

    NSString value of the name of the column.

    Return Value

    YES if column is NULL; NO if not NULL.

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

    @returns NSDictionary of the row results.

    Warning

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

    Declaration

    Objective-C

    - (NSDictionary *)resultDictionary;

    Swift

    func resultDictionary() -> [AnyHashable : Any]!
  • Deprecated

    Returns a dictionary of the row results

    See

    resultDictionary

    Warning

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

    Declaration

    Objective-C

    - (NSDictionary *)resultDict;

    Swift

    func resultDict() -> [AnyHashable : Any]!

Key value coding magic

  • Performs setValue to yield support for key value observing.

    Declaration

    Objective-C

    - (void)kvcMagic:(id)object;

    Swift

    func kvcMagic(_ object: Any!)

    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.