Get field values from an NSArray with CoreData content

1

I have a table in coredata with some fields, I can get the size of these values but I need the values of each field, I have this code:

var request:NSFetchRequest = NSFetchRequest(entityName: "Radar") //my table in coredata

let appDelegate:AppDelegate = (UIApplication.sharedApplication().delegate as! AppDelegate)
let context:NSManagedObjectContext = appDelegate.managedObjectContext!

request.returnsObjectsAsFaults = false

var results:NSArray = context.executeFetchRequest(request, error: nil)!

println(results.count) //this is the count that i can do

But I need more, Radar has these fields: Desc , Lat , Long and I need your values to create a Annotation .

    
asked by anonymous 12.06.2015 / 23:48

1 answer

2

I was able to solve it, for those who need it here:

if results.count > 0
{
    for result in results
    {
         if let r = result as? Radar{
             //now you can access the properties of Radar in r
             println(r.descr)
         } else{
             println("Could not cast fetch result to Radar")
         }
    }   
}
    
13.06.2015 / 00:27