i have an array which haves some values in this ["April : 2016 : P 2 : A 28"] pattern , i want to add the year which is 2016 here , as an section so that i can have a tableView like :
2016
April : 2016 : P 92 : A 528
March : 2016 : P 42 : A 128
May : 2016 : P 12 : A 238
June : 2016 : P 23 : A 268
2017
Jan : 2016 : P 92 : A 528
April : 2016 : P 42 : A 128
Dec : 2016 : P 12 : A 238
Oct : 2016 : P 23 : A 268
how am gonna do that i tired this
i created a struct
struct datesStruct {
var sectionYear : String!
var sectionMonth : [String]!
}
for set in setOfMonths {
datesStructArray.append(datesStruct(sectionYear: "\(yearInt)", sectionMonth: newArrayofValues))
// here `yearInt` is the year which have to be my section for records and i pulled it from the `newArrayofValues` array
tableView.reloadData()
}
in output there's no section even now i have duplicated record on my table ?
any idea how can i add section using a value from a record which looks like this ["April : 2016 : P 2 : A 28"] any help would be much appreciated
update:
now am getting section but sections are repeating (duplicate entry of same section) is my code:
for set in setOfMonths {
datesStructArray.append(datesStruct(sectionYear: "\(yearInt)", sectionMonth: newArrayofValues)) // here newArrayOfValue is an array
tableView.reloadData()
}
my output:
2016
Jan : 2016 : P 92 : A 528
2016
April : 2016 : P 42 : A 128
2016
Dec : 2016 : P 12 : A 238
2017
Oct : 2017 : P 23 : A 268
but what i want is :
2016
Jan : 2016 : P 92 : A 528
April : 2016 : P 42 : A 128
Dec : 2016 : P 12 : A 238
2017
Oct : 2017 : P 23 : A 268