Basically I have an entity called TimeLoc that has three attributes: time, latitude and longitude. And their types are Date, Double and Double respectively. I got stuck when I was trying to make a request with filter on attribute time.
Here is my code:
...
var appDel: AppDelegate = (UIApplication.sharedApplication().delegate as! AppDelegate)
var context: NSManagedObjectContext = self.managedObjectContext!
var request = NSFetchRequest(entityName: "TimeLoc")
var endTime = NSDate()
var startTime = NSDate(timeIntervalSinceNow: -65)
let predicate = NSPredicate(format: "time>= \(startTime) AND time<= \(endTime)")
request.predicate = predicate
var results: NSArray = context.executeFetchRequest(request, error: nil)!
...
And I got the following error: 'Unable to parse the format string "time>= 2015-07-14 03:24:03 +0000 AND time<= 2015-07-14 03:25:08 +0000"'
How should I fix this? I have googled a bit but all the solutions I found were in Objective-C. It would be great if someone can answer me in Swift.
Edit: As V-Xtreme suggested, an answer to this problem can be find in Glauco Neves's answer to this question