add canEdit canDelete to models, default to true
change icloud contatiner
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
<string>development</string>
|
<string>development</string>
|
||||||
<key>com.apple.developer.icloud-container-identifiers</key>
|
<key>com.apple.developer.icloud-container-identifiers</key>
|
||||||
<array>
|
<array>
|
||||||
<string>iCloud.com.88oak.feels</string>
|
<string>iCloud.com.88oak.ifeel</string>
|
||||||
</array>
|
</array>
|
||||||
<key>com.apple.developer.icloud-services</key>
|
<key>com.apple.developer.icloud-services</key>
|
||||||
<array>
|
<array>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<string>development</string>
|
<string>development</string>
|
||||||
<key>com.apple.developer.icloud-container-identifiers</key>
|
<key>com.apple.developer.icloud-container-identifiers</key>
|
||||||
<array>
|
<array>
|
||||||
<string>iCloud.com.88oak.feelsDebug</string>
|
<string>iCloud.com.88oak.ifeel</string>
|
||||||
</array>
|
</array>
|
||||||
<key>com.apple.developer.icloud-services</key>
|
<key>com.apple.developer.icloud-services</key>
|
||||||
<array>
|
<array>
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="19574" systemVersion="21C52" minimumToolsVersion="Automatic" sourceLanguage="Swift" usedWithCloudKit="YES" userDefinedModelVersionIdentifier="">
|
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="19574" systemVersion="21C52" minimumToolsVersion="Automatic" sourceLanguage="Swift" usedWithCloudKit="YES" userDefinedModelVersionIdentifier="">
|
||||||
<entity name="MoodEntry" representedClassName="MoodEntry" syncable="YES" codeGenerationType="class">
|
<entity name="MoodEntry" representedClassName="MoodEntry" syncable="YES" codeGenerationType="class">
|
||||||
|
<attribute name="canDelete" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
|
||||||
|
<attribute name="canEdit" optional="YES" attributeType="Boolean" usesScalarValueType="YES"/>
|
||||||
<attribute name="forDate" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
|
<attribute name="forDate" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
|
||||||
<attribute name="moodValue" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES"/>
|
<attribute name="moodValue" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES"/>
|
||||||
<attribute name="timestamp" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
|
<attribute name="timestamp" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
|
||||||
<attribute name="weekDay" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES"/>
|
<attribute name="weekDay" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES"/>
|
||||||
</entity>
|
</entity>
|
||||||
<elements>
|
<elements>
|
||||||
<element name="MoodEntry" positionX="-63" positionY="-18" width="128" height="89"/>
|
<element name="MoodEntry" positionX="-63" positionY="-18" width="128" height="119"/>
|
||||||
</elements>
|
</elements>
|
||||||
</model>
|
</model>
|
||||||
@@ -41,4 +41,5 @@ struct FeelsApp: App {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ class PersistenceController {
|
|||||||
newItem.moodValue = Int16(mood.rawValue)
|
newItem.moodValue = Int16(mood.rawValue)
|
||||||
newItem.forDate = date
|
newItem.forDate = date
|
||||||
newItem.weekDay = Int16(Calendar.current.component(.weekday, from: date))
|
newItem.weekDay = Int16(Calendar.current.component(.weekday, from: date))
|
||||||
|
newItem.canEdit = true
|
||||||
|
newItem.canDelete = true
|
||||||
|
|
||||||
do {
|
do {
|
||||||
try viewContext.save()
|
try viewContext.save()
|
||||||
@@ -99,6 +101,8 @@ class PersistenceController {
|
|||||||
let newItem = MoodEntry(context: viewContext)
|
let newItem = MoodEntry(context: viewContext)
|
||||||
newItem.timestamp = Date()
|
newItem.timestamp = Date()
|
||||||
newItem.moodValue = Int16(Mood.allValues.randomElement()!.rawValue)
|
newItem.moodValue = Int16(Mood.allValues.randomElement()!.rawValue)
|
||||||
|
newItem.canEdit = true
|
||||||
|
newItem.canDelete = true
|
||||||
|
|
||||||
let date = Calendar.current.date(byAdding: .day, value: -idx, to: Date())!
|
let date = Calendar.current.date(byAdding: .day, value: -idx, to: Date())!
|
||||||
newItem.forDate = date
|
newItem.forDate = date
|
||||||
@@ -119,6 +123,8 @@ class PersistenceController {
|
|||||||
let newItem = MoodEntry(context: viewContext)
|
let newItem = MoodEntry(context: viewContext)
|
||||||
newItem.timestamp = Calendar.current.date(byAdding: .day, value: -idx, to: Date())
|
newItem.timestamp = Calendar.current.date(byAdding: .day, value: -idx, to: Date())
|
||||||
newItem.moodValue = Int16(Mood.allValues.randomElement()!.rawValue)
|
newItem.moodValue = Int16(Mood.allValues.randomElement()!.rawValue)
|
||||||
|
newItem.canEdit = true
|
||||||
|
newItem.canDelete = true
|
||||||
|
|
||||||
let date = Calendar.current.date(byAdding: .day, value: -idx, to: Date())!
|
let date = Calendar.current.date(byAdding: .day, value: -idx, to: Date())!
|
||||||
newItem.forDate = date
|
newItem.forDate = date
|
||||||
@@ -173,6 +179,8 @@ class PersistenceController {
|
|||||||
let date = Calendar.current.date(byAdding: .day, value: -idx, to: Date())!
|
let date = Calendar.current.date(byAdding: .day, value: -idx, to: Date())!
|
||||||
newItem.forDate = date
|
newItem.forDate = date
|
||||||
newItem.weekDay = Int16(Calendar.current.component(.weekday, from: date))
|
newItem.weekDay = Int16(Calendar.current.component(.weekday, from: date))
|
||||||
|
newItem.canEdit = true
|
||||||
|
newItem.canDelete = true
|
||||||
entries.append(newItem)
|
entries.append(newItem)
|
||||||
}
|
}
|
||||||
return entries
|
return entries
|
||||||
@@ -185,12 +193,7 @@ class PersistenceController {
|
|||||||
if inMemory {
|
if inMemory {
|
||||||
container.persistentStoreDescriptions.first!.url = URL(fileURLWithPath: "/dev/null")
|
container.persistentStoreDescriptions.first!.url = URL(fileURLWithPath: "/dev/null")
|
||||||
}
|
}
|
||||||
container.viewContext.automaticallyMergesChangesFromParent = true
|
|
||||||
|
|
||||||
for description in container.persistentStoreDescriptions {
|
|
||||||
description.setOption(true as NSNumber, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey)
|
|
||||||
description.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey)
|
|
||||||
}
|
|
||||||
|
|
||||||
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
|
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
|
||||||
if let error = error as NSError? {
|
if let error = error as NSError? {
|
||||||
@@ -208,6 +211,13 @@ class PersistenceController {
|
|||||||
fatalError("Unresolved error \(error), \(error.userInfo)")
|
fatalError("Unresolved error \(error), \(error.userInfo)")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
container.viewContext.automaticallyMergesChangesFromParent = true
|
||||||
|
|
||||||
|
for description in container.persistentStoreDescriptions {
|
||||||
|
description.setOption(true as NSNumber, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey)
|
||||||
|
description.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -171,7 +171,6 @@ struct ContentView: View {
|
|||||||
Text(dayFormat(fromDate:entry.forDate!))
|
Text(dayFormat(fromDate:entry.forDate!))
|
||||||
.font(.title3)
|
.font(.title3)
|
||||||
.foregroundColor(Color(UIColor.label))
|
.foregroundColor(Color(UIColor.label))
|
||||||
|
|
||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
.multilineTextAlignment(.leading)
|
.multilineTextAlignment(.leading)
|
||||||
|
|||||||
Reference in New Issue
Block a user