Skip to content

Commit

Permalink
Merge pull request #44 from JYPjoy/develop
Browse files Browse the repository at this point in the history
[v1.0.0] Version 1.0.0
  • Loading branch information
JYPjoy authored Feb 26, 2024
2 parents 3143b5e + 8e4bee2 commit 7b868ae
Show file tree
Hide file tree
Showing 75 changed files with 3,110 additions and 39 deletions.
47 changes: 27 additions & 20 deletions Reflection.swiftpm/.swiftpm/playgrounds/CachedManifest.plist
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,45 @@
<dict>
<key>manifestData</key>
<data>
eyJkZXBlbmRlbmNpZXMiOltdLCJkaXNwbGF5TmFtZSI6IuuCmOydmCDslbEi
eyJkZXBlbmRlbmNpZXMiOltdLCJkaXNwbGF5TmFtZSI6IlJlZmxlY3Rpb24i
LCJwYWNrYWdlS2luZCI6eyJyb290Ijp7fX0sInBsYXRmb3JtcyI6W3sib3B0
aW9ucyI6W10sInBsYXRmb3JtTmFtZSI6ImlvcyIsInZlcnNpb24iOiIxNi4w
In1dLCJwcm9kdWN0cyI6W3sibmFtZSI6IuuCmOydmCDslbEiLCJzZXR0aW5n
In1dLCJwcm9kdWN0cyI6W3sibmFtZSI6IlJlZmxlY3Rpb24iLCJzZXR0aW5n
cyI6W3siYnVuZGxlSWRlbnRpZmllciI6WyJjb20uanlwam95LnJlZmxlY3Rp
b24iXX0seyJ0ZWFtSWRlbnRpZmllciI6WyJYR0hEUUc2NlU1Il19LHsiZGlz
cGxheVZlcnNpb24iOlsiMS4wLjAiXX0seyJidW5kbGVWZXJzaW9uIjpbIjEi
XX0seyJpT1NBcHBJbmZvIjpbeyJhY2NlbnRDb2xvciI6eyJwcmVzZXRDb2xv
ciI6eyJwcmVzZXRDb2xvciI6eyJyYXdWYWx1ZSI6InBpbmsifX19LCJhcHBJ
Y29uIjp7InBsYWNlaG9sZGVyIjp7Imljb24iOnsicmF3VmFsdWUiOiJwYWxl
dHRlIn19fSwiY2FwYWJpbGl0aWVzIjpbXSwic3VwcG9ydGVkRGV2aWNlRmFt
a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pb
XSwic2V0dGluZ3MiOlt7ImtpbmQiOnsiZW5hYmxlVXBjb21pbmdGZWF0dXJl
Ijp7Il8wIjoiQmFyZVNsYXNoUmVnZXhMaXRlcmFscyJ9fSwidG9vbCI6InN3
aWZ0In1dLCJ0eXBlIjoiZXhlY3V0YWJsZSJ9XSwidG9vbHNWZXJzaW9uIjp7
Il92ZXJzaW9uIjoiNS45LjAifX0=
ZnQifV0sInR5cGUiOiJleGVjdXRhYmxlIn1dLCJ0b29sc1ZlcnNpb24iOnsi
X3ZlcnNpb24iOiI1LjkuMCJ9fQ==
</data>
<key>manifestHash</key>
<data>
QiyfDQCZjVoArvX/mz+Z3UmtHc+aBkyY4boMw7f4wgQ=
owJbJfiATS4QyrQpm/RBfiZ6Ik0eHo2AmGu8auy8Pzg=
</data>
<key>schemaVersion</key>
<integer>4</integer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<dict>
<key>accentColorHash</key>
<data>
pnpByLx51dqRe1BR8fDT9a60tjuiRrNUapYe96PH2TE=
Fkd2iMDgBpnGz6RJejYS1+g8UyBitkslD+2JCBKO1Ug=
</data>
<key>appIconHash</key>
<data>
GeS9LYBr7Tw2T9hNC/Igr55lK7gHc57d+zq76y01XFk=
W3oPACk3u7TK1M/97PwjVXJVsZ4GvXprGx/6kgHbdtg=
</data>
<key>thumbnailIsPrerendered</key>
<false/>
Expand Down
Binary file modified 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.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import SwiftUI
struct MyApp: App {
var body: some Scene {
WindowGroup {
ContentView()
SplashView()
}
}
}
12 changes: 0 additions & 12 deletions Reflection.swiftpm/ContentView.swift

This file was deleted.

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
}
}
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 Reflection.swiftpm/Data/CoreDataEntity/ModelingEntities.swift
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
}
}

Loading

0 comments on commit 7b868ae

Please sign in to comment.