if (result.count() > 0) { NSDictionary dict = (NSDictionary)result.objectAtIndex(0); NSArray values = dict.allValues(); if (values.count() > 0) { Object value = values.objectAtIndex(0); if (value instanceof Number) { return ((Number)value).intValue();
if (result.count() > 0) { NSDictionary dict = (NSDictionary)result.objectAtIndex(0); NSArray values = dict.allValues(); if (values.count() > 0) { Object value = values.objectAtIndex(0); if (value instanceof Number) { return ((Number)value).intValue(); } else { try { int c = Integer.parseInt(value.toString()); setObjectArray(new FakeArray(c)); _rowCount = c; } catch (NumberFormatException e) { throw new IllegalStateException("sql "+sql+" returned a wrong result, could not convert "+value+" into an int!"); } }
    public int rowCount() {        EOFetchSpecification spec = databaseDataSource().fetchSpecificationForFetch();        EOEditingContext ec = databaseDataSource().editingContext();        EOModel model = ERXEOAccessUtilities.modelForFetchSpecificationAndEditingContext(spec, ec);        String sql = ERXEOAccessUtilities.sqlForFetchSpecificationAndEditingContext(spec, ec);        int index = sql.indexOf("from");        if (index == -1) {            index = sql.indexOf("FROM");        }        sql = "select count(*) " + sql.substring(index, sql.length());        NSArray result = EOUtilities.rawRowsForSQL(ec, model.name(), sql);        if (result.count() > 0) {            NSDictionary dict = (NSDictionary)result.objectAtIndex(0);            NSArray values = dict.allValues();            if (values.count() > 0) {                Object value = values.objectAtIndex(0);                if (value instanceof Number) {                    return ((Number)value).intValue();                } else {                    try {                        int c = Integer.parseInt(value.toString());                        setObjectArray(new ERFakeNSArray(c));                        return c;                    } catch (NumberFormatException e) {                        throw new IllegalStateException("sql "+sql+" returned a wrong result, could not convert "+value+" into an int!");                    }                }            } else {                throw new IllegalStateException("sql "+sql+" returned no result!");            }        } else {            throw new IllegalStateException("sql "+sql+" returned no result!");        }    }