Repository: realm/realm-swift
File: src/tightdb/objc/support.mm (Objective-C++)

Code before:
        ++col_ndx;
    }
    return YES;
}

BOOL insert_row(size_t row_ndx, tightdb::Table& table, NSArray * data)
{
    /* 
       Assumption:
       - data has been validated by verify_row
    */

    NSEnumerator *enumerator = [data objectEnumerator];
    id obj;

    /* FIXME: handling of tightdb exceptions => return NO */
    size_t col_ndx = 0;
    while (obj = [enumerator nextObject]) {
        DataType type = table.get_column_type(col_ndx);
        switch (type) {
        case type_Bool:
            table.insert_bool(col_ndx, row_ndx, bool([obj boolValue]));
            break;
        case type_DateTime:
            table.insert_datetime(col_ndx, row_ndx, time_t([obj longValue]));
            break;
        case type_Int:
            table.insert_int(col_ndx, row_ndx, int64_t([obj longValue]));
            break;
        case type_Float:
            table.insert_float(col_ndx, row_ndx, float([obj floatValue]));
            break;
        case type_Double:
            table.insert_double(col_ndx, row_ndx, double([obj doubleValue]));
            break;
        case type_String: 
            {
                StringData sd([obj UTF8String]);
                table.insert_string(col_ndx, row_ndx, sd);
            }
            break;
        case type_Binary:
            {
                BinaryData bd([obj getData], [obj getSize]);
                table.insert_binary(col_ndx, row_ndx, bd);
            }
            break;
        case type_Table:
            if ([obj count]) {
                table.clear_subtable(col_ndx, row_ndx);
            }

Review comment (suggestion):
If there is nothing common to do after "ok:", I would definitely 'return result' in the 'case' instead of 'goto ok'. 


Code after:
            else {
                return NO;
            }
            break;
           
        }
        ++col_ndx;
    }
    return YES;
}

BOOL insert_row(size_t row_ndx, tightdb::Table& table, NSArray * data)
{
    /* 
       Assumption:
       - data has been validated by verify_row
    */

    NSEnumerator *enumerator = [data objectEnumerator];
    id obj;

    /* FIXME: handling of tightdb exceptions => return NO */
    size_t col_ndx = 0;
    while (obj = [enumerator nextObject]) {
        DataType type = table.get_column_type(col_ndx);
        switch (type) {
        case type_Bool:
            table.insert_bool(col_ndx, row_ndx, bool([obj boolValue]));
            break;
        case type_DateTime:
            if ([obj isKindOfClass:[NSDate class]]) {
                table.insert_datetime(col_ndx, row_ndx, time_t([obj timeIntervalSince1970]));
            }
            else {
                table.insert_datetime(col_ndx, row_ndx, time_t([obj longValue]));
            }
            break;
        case type_Int:
            table.insert_int(col_ndx, row_ndx, int64_t([obj longValue]));
            break;
        case type_Float:
            table.insert_float(col_ndx, row_ndx, float([obj floatValue]));
            break;
        case type_Double:
            table.insert_double(col_ndx, row_ndx, double([obj doubleValue]));
            break;
        case type_String: 
            {
                StringData sd([obj UTF8String]);
                table.insert_string(col_ndx, row_ndx, sd);
            }