Skip to content

Commit

Permalink
Merge pull request #31 from jeffoio/develop
Browse files Browse the repository at this point in the history
[#30] 습관, 메모 객체
  • Loading branch information
jwonyLee authored Nov 5, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents 28ac43a + 04ddf3d commit 7d17123
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Hazzle/Hazzle/Model/Habit.swift
Original file line number Diff line number Diff line change
@@ -31,4 +31,20 @@ class Habit: Object {
@objc dynamic var count: Int = 0
var grid: List<Bool> = List<Bool>()
var memo: List<Memo> = List<Memo>()

override init() {
super.init()
initGrid()
}
func initGrid() {
for _ in 0..<goal {
grid.append(false)
}
}
func conutUp() {
count += 1
if goal < count { return }
let index = grid.filter { $0 == false }.indices.randomElement()
grid[index!] = true
}
}
1 change: 1 addition & 0 deletions Hazzle/Hazzle/Model/Memo.swift
Original file line number Diff line number Diff line change
@@ -20,4 +20,5 @@ class Memo: Object {
@objc dynamic var identifier: String = UUID().uuidString
@objc dynamic var date: Date = Date()
@objc dynamic var content: String = ""
let habitName = LinkingObjects(fromType: Habit.self, property: "memo")
}

0 comments on commit 7d17123

Please sign in to comment.