I want to store the last 7 data of Core Data in an array. The structure of the entity is as follows. date, title, goal, nogoal, id.
I want to store the last 7 goal records in an array. If there is an angel who can do it, please help me.
I want to store the last 7 data of Core Data in an array. The structure of the entity is as follows. date, title, goal, nogoal, id.
I want to store the last 7 goal records in an array. If there is an angel who can do it, please help me.
You should define a struct with the var, date, title, goal, nogoal, id
struct MyData {
var date: Date
var title: String
var goal: Int
var nogoal: ???
var id: ???
}
Then create ab array
var myData : [MyData] = []
Read the elements from core Data, load each in a new MyData value and append to the array.
Please tell if you miss something.
Can't i just store specific attributes of an entity as an array?
Yes you can. Just define the struct to contain those elements you want.