forked from yagom-academy/ios-diary
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
132 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
disabled_rules: | ||
- trailing_whitespace | ||
- line_length | ||
|
||
excluded: | ||
- Pods | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// Diary+CoreDataClass.swift | ||
// Diary | ||
// | ||
// Created by 1 on 2023/09/01. | ||
// | ||
// | ||
|
||
import Foundation | ||
import CoreData | ||
|
||
@objc(Diary) | ||
public class Diary: NSManagedObject { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// Diary+CoreDataProperties.swift | ||
// Diary | ||
// | ||
// Created by 1 on 2023/09/01. | ||
// | ||
// | ||
|
||
import Foundation | ||
import CoreData | ||
|
||
|
||
extension Diary { | ||
|
||
@nonobjc public class func fetchRequest() -> NSFetchRequest<Diary> { | ||
return NSFetchRequest<Diary>(entityName: "Diary") | ||
} | ||
|
||
@NSManaged public var title: String? | ||
@NSManaged public var body: String? | ||
@NSManaged public var createdAt: Date? | ||
@NSManaged public var id: UUID? | ||
|
||
} | ||
|
||
extension Diary : Identifiable { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// CoreDataManager.swift | ||
// Diary | ||
// | ||
// Created by Max, Hemg on 2023/09/01. | ||
// | ||
|
||
import Foundation | ||
import CoreData | ||
|
||
class CoreDataManager { | ||
static let shard = CoreDataManager() | ||
private init() {} | ||
|
||
// MARK: - Core Data stack | ||
lazy var persistentContainer: NSPersistentContainer = { | ||
let container = NSPersistentContainer(name: "Diary") | ||
container.loadPersistentStores(completionHandler: { (storeDescription, error) in | ||
if let error = error as NSError? { | ||
fatalError("Unresolved error \(error), \(error.userInfo)") | ||
} | ||
}) | ||
return container | ||
}() | ||
|
||
// MARK: - Core Data Saving support | ||
func saveContext () { | ||
let context = persistentContainer.viewContext | ||
if context.hasChanges { | ||
do { | ||
try context.save() | ||
} catch { | ||
let nserror = error as NSError | ||
fatalError("Unresolved error \(nserror), \(nserror.userInfo)") | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="1" systemVersion="11A491" minimumToolsVersion="Automatic" sourceLanguage="Swift" usedWithCloudKit="false" userDefinedModelVersionIdentifier=""> | ||
<elements/> | ||
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="21279" systemVersion="22D49" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier=""> | ||
<entity name="Diary" representedClassName="Diary" syncable="YES"> | ||
<attribute name="body" optional="YES" attributeType="String"/> | ||
<attribute name="createdAt" optional="YES" attributeType="Date" usesScalarValueType="NO"/> | ||
<attribute name="id" optional="YES" attributeType="UUID" usesScalarValueType="NO"/> | ||
<attribute name="title" optional="YES" attributeType="String"/> | ||
</entity> | ||
</model> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters