我想根据核心数据中的数据显示图表。怎么办呢?
var myArray: Array <Float> = [0]
let appDel:AppDelegate = UIApplication.sharedApplication().delegate as AppDelegate
let context:NSManagedObjectContext = appDel.managedObjectContext!
let request = NSFetchRequest(entityName: "StudentCGPA")
request.returnsObjectsAsFaults = false;
var results:NSArray = context.executeFetchRequest(request, error: nil)!
if results.count > 0 {
for student in results{
var thisstudent = student as StudentCGPA
'the fetched data should output to myArray
}
}else {
}
答案 0 :(得分:1)
如果您想用浮点数填充新数组,只需执行以下操作:
myArray.append(thisstudent.yourFloatEntity)