File tree Expand file tree Collapse file tree 3 files changed +12
-0
lines changed
Bookworm.xcdatamodeld/Bookworm.xcdatamodel Expand file tree Collapse file tree 3 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ struct AddBookView: View {
64
64
newBook. rating = Int16 ( rating)
65
65
newBook. genre = genre
66
66
newBook. review = review
67
+ newBook. date = Date . now
67
68
68
69
try ? moc. save ( )
69
70
dismiss ( )
Original file line number Diff line number Diff line change 2
2
<model type =" com.apple.IDECoreDataModeler.DataModel" documentVersion =" 1.0" lastSavedToolsVersion =" 21513" systemVersion =" 22D68" minimumToolsVersion =" Automatic" sourceLanguage =" Swift" userDefinedModelVersionIdentifier =" " >
3
3
<entity name =" Book" representedClassName =" Book" syncable =" YES" codeGenerationType =" class" >
4
4
<attribute name =" author" optional =" YES" attributeType =" String" />
5
+ <attribute name =" date" optional =" YES" attributeType =" Date" usesScalarValueType =" NO" />
5
6
<attribute name =" genre" optional =" YES" attributeType =" String" />
6
7
<attribute name =" id" optional =" YES" attributeType =" UUID" usesScalarValueType =" NO" />
7
8
<attribute name =" rating" optional =" YES" attributeType =" Integer 16" defaultValueString =" 0" usesScalarValueType =" YES" />
Original file line number Diff line number Diff line change @@ -41,6 +41,16 @@ struct DetailView: View {
41
41
42
42
RatingView ( rating: . constant( Int ( book. rating) ) )
43
43
. font ( . largeTitle)
44
+
45
+ Rectangle ( )
46
+ . frame ( height: 1 )
47
+ . foregroundColor ( . secondary. opacity ( 0.5 ) )
48
+ . padding ( . vertical)
49
+
50
+ HStack {
51
+ Text ( " Added in: " )
52
+ Text ( book. date ?? Date ( ) , style: . date)
53
+ }
44
54
}
45
55
. navigationTitle ( book. title ?? " Unknown Book " )
46
56
. navigationBarTitleDisplayMode ( . inline)
You can’t perform that action at this time.
0 commit comments