Predicate com CAST

By : Gian

Accessing database .sqlite by sql query normally, I can use the function CAST('column' as decimal).

By NSPredicate, using CoreData, how to make this CAST? I have one column of type String and I need make one cast to decimal type for compare with other decimal number.

By : Gian


You should not care about how SQLite stores your object graph. In fact, SQLite is pretty liberal about types, so what you should really rely on is the type you specified in your model and your model subclasses.

If your column is a String use this:

NSPredicate(format: "column = %@", "\(decimal)")

You can then process the result further if you need a number rather than a string.

By : Mundi

This video can help you solving your question :)
By: admin