-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from JYPjoy/develop
[v1.0.0] Version 1.0.0
- Loading branch information
Showing
75 changed files
with
3,110 additions
and
39 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
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
Binary file modified
BIN
+20.5 KB
(130%)
Reflection.swiftpm/.swiftpm/playgrounds/DocumentThumbnail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions
7
Reflection.swiftpm/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ import SwiftUI | |
struct MyApp: App { | ||
var body: some Scene { | ||
WindowGroup { | ||
ContentView() | ||
SplashView() | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
53 changes: 53 additions & 0 deletions
53
Reflection.swiftpm/Data/CoreDataEntity/ColorChipEntity+CoreDataClass.swift
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,53 @@ | ||
import Foundation | ||
import CoreData | ||
|
||
@objc(ColorChipEntity) | ||
final class ColorChipEntity: NSManagedObject, Identifiable { | ||
@NSManaged public var identifier: UUID | ||
@NSManaged public var colorName: String | ||
@NSManaged public var colorList: String //hex값 담기게 됨 | ||
@NSManaged public var memories: Set<MemoryEntity> | ||
|
||
var id: UUID { | ||
identifier | ||
} | ||
} | ||
|
||
extension ColorChipEntity { | ||
@nonobjc public class func fetchRequest() -> NSFetchRequest<ColorChipEntity> { | ||
return NSFetchRequest<ColorChipEntity>(entityName: "ColorChipEntity") | ||
} | ||
|
||
@objc(addMemoriesObject:) | ||
@NSManaged public func addToMemories(_ value: MemoryEntity) | ||
|
||
@objc(removeMemoriesObject:) | ||
@NSManaged public func removeFromMemories(_ value: MemoryEntity) | ||
|
||
@objc(addMemories:) | ||
@NSManaged public func addToMemories(_ values: NSSet) | ||
|
||
@objc(removeMemories:) | ||
@NSManaged public func removeFromMemories(_ values: NSSet) | ||
} | ||
|
||
extension ColorChipEntity { | ||
|
||
convenience init(context: NSManagedObjectContext, colorChip: ColorChip) { | ||
self.init(context: context) | ||
self.identifier = colorChip.id | ||
self.colorName = colorChip.colorName | ||
self.colorList = colorChip.colorList | ||
} | ||
|
||
func toDomain() -> ColorChip { | ||
return ColorChip(id: self.identifier, colorName: self.colorName, colorList: self.colorList, memories: self.memories.map{ $0.toDomain() }) | ||
} | ||
} | ||
|
||
extension ColorChipEntity: Comparable { | ||
|
||
public static func < (lhs: ColorChipEntity, rhs: ColorChipEntity) -> Bool { | ||
return lhs.id < rhs.id | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
Reflection.swiftpm/Data/CoreDataEntity/MemoryEntity+CoreDataClass.swift
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,53 @@ | ||
import Foundation | ||
import CoreData | ||
|
||
@objc(MemoryEntity) | ||
final class MemoryEntity: NSManagedObject, Identifiable { | ||
@NSManaged public var identifier: UUID | ||
@NSManaged public var picture: Data? | ||
|
||
@NSManaged public var title: String | ||
@NSManaged public var date: Date | ||
@NSManaged public var reflection: String | ||
@NSManaged var colorChip: Set<ColorChipEntity> | ||
// 날짜, 위치 정보 추가될 수도 | ||
|
||
var id: UUID { | ||
identifier | ||
} | ||
} | ||
|
||
extension MemoryEntity { | ||
@nonobjc public class func fetchRequest() -> NSFetchRequest<MemoryEntity> { | ||
return NSFetchRequest<MemoryEntity>(entityName: "MemoryEntity") | ||
} | ||
|
||
@objc(addColorChipObject:) | ||
@NSManaged public func addToColorChip(_ value: ColorChipEntity) | ||
|
||
@objc(removeColorChipObject:) | ||
@NSManaged public func removeFromColorChip(_ value: ColorChipEntity) | ||
|
||
@objc(addColorChip:) | ||
@NSManaged public func addToColorChip(_ values: NSSet) | ||
|
||
@objc(removeColorChip:) | ||
@NSManaged public func removeFromColorChip(_ values: NSSet) | ||
} | ||
|
||
extension MemoryEntity { | ||
|
||
@discardableResult | ||
convenience init(context: NSManagedObjectContext, memory: Memory) { | ||
self.init(context: context) | ||
self.identifier = memory.id | ||
self.picture = memory.picture | ||
self.title = memory.title | ||
self.date = memory.date | ||
self.reflection = memory.reflection | ||
} | ||
|
||
func toDomain() -> Memory { | ||
return Memory(id: self.id, picture: self.picture, title: self.title, date: self.date, reflection: self.reflection) | ||
} | ||
} |
100 changes: 100 additions & 0 deletions
100
Reflection.swiftpm/Data/CoreDataEntity/ModelingEntities.swift
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,100 @@ | ||
import Foundation | ||
import CoreData | ||
|
||
// MARK: - Initialize ColorDataManager | ||
extension CoreDataManager { | ||
// MARK: - ColorChip | ||
/// Create the colorChip with all attributes | ||
static func createColorChip() -> NSManagedObjectModel { | ||
/// ColorChip 관련 코드 | ||
let colorChipEntity = NSEntityDescription() | ||
colorChipEntity.name = "ColorChipEntity" | ||
colorChipEntity.managedObjectClassName = "ColorChipEntity" | ||
|
||
let colorIdAttribute = NSAttributeDescription() | ||
colorIdAttribute.name = "identifier" | ||
colorIdAttribute.type = .uuid | ||
colorChipEntity.properties.append(colorIdAttribute) | ||
|
||
let colorNameAttribute = NSAttributeDescription() | ||
colorNameAttribute.name = "colorName" | ||
colorNameAttribute.type = .string | ||
colorChipEntity.properties.append(colorNameAttribute) | ||
|
||
let colorListAttribute = NSAttributeDescription() | ||
colorListAttribute.name = "colorList" | ||
colorListAttribute.type = .string | ||
colorChipEntity.properties.append(colorListAttribute) | ||
|
||
let model = NSManagedObjectModel() | ||
|
||
/// ColorChip 과 Memory 간의 관계 정의 | ||
let memory = CoreDataManager.createMemory() | ||
|
||
let memoryRelation = NSRelationshipDescription() | ||
memoryRelation.destinationEntity = memory | ||
memoryRelation.name = "memories" | ||
memoryRelation.minCount = 0 | ||
memoryRelation.maxCount = 0 | ||
memoryRelation.isOptional = true | ||
memoryRelation.deleteRule = .nullifyDeleteRule | ||
|
||
/* | ||
For a to-one relationship, set maxCount to 1. | ||
For a to-many relationship, set maxCount to a number greater than 1 to impose an upper limit; otherwise, use 0 to allow an unlimited number of referenced objects. | ||
*/ | ||
|
||
let colorChipRelation = NSRelationshipDescription() | ||
colorChipRelation.destinationEntity = colorChipEntity | ||
colorChipRelation.name = "colorChip" | ||
colorChipRelation.minCount = 0 | ||
colorChipRelation.maxCount = 0 | ||
colorChipRelation.isOptional = true | ||
colorChipRelation.deleteRule = .nullifyDeleteRule | ||
|
||
memoryRelation.inverseRelationship = colorChipRelation | ||
colorChipRelation.inverseRelationship = memoryRelation | ||
|
||
colorChipEntity.properties.append(memoryRelation) | ||
memory.properties.append(colorChipRelation) | ||
|
||
model.entities = [colorChipEntity, memory] | ||
return model | ||
} | ||
|
||
// MARK: - Memory | ||
// Create the Memory model with all attributes | ||
static func createMemory() -> NSEntityDescription { | ||
let memoryEntity = NSEntityDescription() | ||
memoryEntity.name = "MemoryEntity" | ||
memoryEntity.managedObjectClassName = "MemoryEntity" | ||
|
||
let memoryIdAttribute = NSAttributeDescription() | ||
memoryIdAttribute.name = "identifier" | ||
memoryIdAttribute.type = .uuid | ||
memoryEntity.properties.append(memoryIdAttribute) | ||
|
||
let memoryPictureAttribute = NSAttributeDescription() | ||
memoryPictureAttribute.name = "picture" | ||
memoryPictureAttribute.type = .binaryData | ||
memoryEntity.properties.append(memoryPictureAttribute) | ||
|
||
let memoryTitleAttribute = NSAttributeDescription() | ||
memoryTitleAttribute.name = "title" | ||
memoryTitleAttribute.type = .string | ||
memoryEntity.properties.append(memoryTitleAttribute) | ||
|
||
let memoryDateAttribute = NSAttributeDescription() | ||
memoryDateAttribute.name = "date" | ||
memoryDateAttribute.type = .date | ||
memoryEntity.properties.append(memoryDateAttribute) | ||
|
||
let memoryReflectionAttribute = NSAttributeDescription() | ||
memoryReflectionAttribute.name = "reflection" | ||
memoryReflectionAttribute.type = .string | ||
memoryEntity.properties.append(memoryReflectionAttribute) | ||
|
||
return memoryEntity | ||
} | ||
} | ||
|
Oops, something went wrong.