Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. //CODING
  2.  
  3. override func viewDidLoad() {
  4. super.viewDidLoad()
  5.  
  6. let cal = NSCalendar.currentCalendar()
  7. var date = NSDate()
  8. for i in 1 ... 30 {
  9.  
  10. let dateFormatter_week = NSDateFormatter()
  11. dateFormatter_week.dateFormat = "E"
  12. let dateFormatter_date = NSDateFormatter()
  13. dateFormatter_date.dateFormat = "dd"
  14.  
  15. var str_week = dateFormatter_week.stringFromDate(date)
  16. var str_date = dateFormatter_date.stringFromDate(date)
  17.  
  18. arr_week.append(str_week)
  19. arr_date.append(str_date)
  20.  
  21. date = cal.dateByAddingUnit(.DayCalendarUnit, value: -1, toDate: date, options:
  22. nil)!
  23. }
  24. }
  25.  
  26. func collectionView(collectionView: UICollectionView, numberOfItemsInSection
  27. section: Int) -> Int {
  28. return arr_date.count
  29.  
  30. }
  31.  
  32. func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath:
  33. NSIndexPath) -> UICollectionViewCell {
  34.  
  35. var cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell",
  36. forIndexPath: indexPath) as myViewCell
  37.  
  38.  
  39. cell.week_label.text = arr_week[indexPath.row]
  40. cell.date_label.text = arr_date[indexPath.row]
  41.  
  42. return cell
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement