如何将核心数据输出到数组中以生成图形(Swift)

时间:2015-04-17 23:39:13

标签: swift core-data xcode6

我想根据核心数据中的数据显示图表。怎么办呢?

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 {

    }

1 个答案:

答案 0 :(得分:1)

如果您想用浮点数填充新数组,只需执行以下操作:

myArray.append(thisstudent.yourFloatEntity)