 }
 
 public func <<<T>(left: Attribute<T>, right: Range<T>) -> NSComparisonPredicate {
-    let rightValue = [right.startIndex as! AnyObject, right.endIndex as! AnyObject] as NSArray
+    let rightValue = [toAnyObject(right.startIndex), toAnyObject(right.endIndex)] as NSArray
     let rightExpression = NSExpression(forConstantValue: rightValue)
     
     return NSComparisonPredicate(

prefix public func !(left: Attribute<Bool>) -> NSComparisonPredicate {
    return left == false
}

public func ==<T>(left: Attribute<T>, right: T) -> NSComparisonPredicate {
    return NSComparisonPredicate(
        leftExpression: left.expression,
        rightExpression: expressionForValue(right),
        modifier: .DirectPredicateModifier,
        type: .EqualToPredicateOperatorType,
        options: left.comparisonPredicateOptions()
