Skip to content

Instantly share code, notes, and snippets.

View michal-majchrzycki's full-sized avatar

Michal Majchrzycki michal-majchrzycki

  • Poland, Poznan
View GitHub Profile
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: cellIdentifier, for: indexPath) as! CalendarViewCell
cell.dateLabel.text = self.calendarArray?[indexPath.row] as? String
return cell
}
func arrayOfDates() -> NSArray {
let numberOfDays: Int = 14
let startDate = Date()
let formatter: DateFormatter = DateFormatter()
formatter.dateFormat = "EEE d/M"
let calendar = Calendar.current
var offset = DateComponents()
var dates: [Any] = [formatter.string(from: startDate)]
var currentDate = Date()
var calendarArray: NSArray?
let entity = NSEntityDescription.entityForName("Fruits", inManagedObjectContext: context)!
fetchRequest.entity = entity
fetchRequest.sortDescriptors = [sortTitle]
ex.expressionResultType = .DecimalAttributeType
fetchRequest.propertiesToFetch = ["colors"]
fetchRequest.propertiesToGroupBy = ["colors"]
fetchRequest.resultType = .DictionaryResultType
let matchingObjects = try! context.executeFetchRequest(fetchRequest) as AnyObject
self.expenseCategory = matchingObjects
func getMeColor() -> NSFetchRequest {
let sortTitle = NSSortDescriptor(key: "date", ascending: true)
self.fetchRequest = NSFetchRequest(entityName: "Fruits")
let context = managedObjectContext