-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
프로젝트 매니저 [STEP 2] Jusbug #314
base: ic_9_jusbug2
Are you sure you want to change the base?
Changes from all commits
d06f237
c292142
dbe8e6f
d6ed629
d163f0d
5387839
9ebebcf
a1bd7de
12bea3c
8de0d3f
d1e5e0d
d9a29df
abaa70c
2eae03c
849b576
58b53b0
6a43d5d
c00e826
2713a6d
4c739ff
7a02687
fa75868
add6a32
ba6f227
9d39089
f41e504
8ac0065
b1665e7
5893e1d
0a8e680
94bda6b
566db1f
afe3a9c
9971743
841a7fa
7b5ea52
87ed7c5
d54ad48
6bc8449
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// | ||
// CoreDataManager.swift | ||
// ProjectManager | ||
// | ||
// Created by Jusbug on 2023/09/27. | ||
// | ||
|
||
import UIKit | ||
|
||
final class CoreDataManager { | ||
|
||
static var shared: CoreDataManager = CoreDataManager() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 추후에 변경될 여지가 있나요 ? |
||
let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext | ||
var entities: [Entity] = [] | ||
|
||
func saveToContext() { | ||
do { | ||
try context.save() | ||
} catch { | ||
print(error.localizedDescription) | ||
} | ||
} | ||
|
||
func createEntity(title: String, body: String, duration: Date, status: Status) { | ||
let newEntity = Entity(context: context) | ||
newEntity.title = title | ||
newEntity.body = body | ||
newEntity.duration = duration | ||
newEntity.status = status.rawValue | ||
|
||
saveToContext() | ||
getAllEntity() | ||
} | ||
|
||
func getAllEntity() { | ||
do { | ||
entities = try context.fetch(Entity.fetchRequest()) | ||
} catch { | ||
print(error.localizedDescription) | ||
} | ||
} | ||
|
||
func updateEntity(entity: Entity, newTitle: String, newBody: String, newDuration: Date) { | ||
entity.title = newTitle | ||
entity.body = newBody | ||
entity.duration = newDuration | ||
|
||
saveToContext() | ||
} | ||
|
||
func deleteEntity(entity: Entity) { | ||
context.delete(entity) | ||
|
||
saveToContext() | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// Entity+CoreDataClass.swift | ||
// ProjectManager | ||
// | ||
// Created by Jusbug on 2023/09/26. | ||
// | ||
// | ||
|
||
import Foundation | ||
import CoreData | ||
|
||
@objc(Entity) | ||
public class Entity: NSManagedObject { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Entity라는 이름을 모델이름으로 사용하실건가요 ? |
||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// Entity+CoreDataProperties.swift | ||
// ProjectManager | ||
// | ||
// Created by Jusbug on 2023/09/26. | ||
// | ||
// | ||
|
||
import Foundation | ||
import CoreData | ||
|
||
|
||
extension Entity { | ||
|
||
@nonobjc public class func fetchRequest() -> NSFetchRequest<Entity> { | ||
return NSFetchRequest<Entity>(entityName: "Entity") | ||
} | ||
|
||
@NSManaged public var duration: Date? | ||
@NSManaged public var title: String? | ||
@NSManaged public var body: String? | ||
@NSManaged public var status: String? | ||
|
||
} | ||
|
||
extension Entity : Identifiable { | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,21 +9,43 @@ | |
/* Begin PBXBuildFile section */ | ||
C7431F0625F51E1D0094C4CF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7431F0525F51E1D0094C4CF /* AppDelegate.swift */; }; | ||
C7431F0825F51E1D0094C4CF /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7431F0725F51E1D0094C4CF /* SceneDelegate.swift */; }; | ||
C7431F0A25F51E1D0094C4CF /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7431F0925F51E1D0094C4CF /* ViewController.swift */; }; | ||
C7431F0A25F51E1D0094C4CF /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7431F0925F51E1D0094C4CF /* MainViewController.swift */; }; | ||
C7431F0D25F51E1D0094C4CF /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C7431F0B25F51E1D0094C4CF /* Main.storyboard */; }; | ||
C7431F0F25F51E1E0094C4CF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C7431F0E25F51E1E0094C4CF /* Assets.xcassets */; }; | ||
C7431F1225F51E1E0094C4CF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C7431F1025F51E1E0094C4CF /* LaunchScreen.storyboard */; }; | ||
D0293F532ACAB3CE00505749 /* DateFormatManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0293F522ACAB3CE00505749 /* DateFormatManager.swift */; }; | ||
D0293F5A2ACBAA2B00505749 /* Status.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0293F592ACBAA2B00505749 /* Status.swift */; }; | ||
D06DA8E52AC2BA9F00314499 /* Todo.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = D06DA8E32AC2BA9F00314499 /* Todo.xcdatamodeld */; }; | ||
D06DA8E82AC2BB0D00314499 /* Entity+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = D06DA8E62AC2BB0D00314499 /* Entity+CoreDataClass.swift */; }; | ||
D06DA8E92AC2BB0D00314499 /* Entity+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = D06DA8E72AC2BB0D00314499 /* Entity+CoreDataProperties.swift */; }; | ||
D06DA8EB2AC3B87200314499 /* CoreDataManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = D06DA8EA2AC3B87200314499 /* CoreDataManager.swift */; }; | ||
D09389A92AC20FC5008A8304 /* CollectionReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D09389A72AC20FC5008A8304 /* CollectionReusableView.swift */; }; | ||
D09389AA2AC20FC5008A8304 /* CollectionReusableView.xib in Resources */ = {isa = PBXBuildFile; fileRef = D09389A82AC20FC5008A8304 /* CollectionReusableView.xib */; }; | ||
D0CED7782ABEAB570081ABE2 /* CollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0CED7762ABEAB570081ABE2 /* CollectionViewCell.swift */; }; | ||
D0CED7792ABEAB570081ABE2 /* CollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = D0CED7772ABEAB570081ABE2 /* CollectionViewCell.xib */; }; | ||
D0CED7812ABEB18D0081ABE2 /* SecondViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0CED7802ABEB18D0081ABE2 /* SecondViewController.swift */; }; | ||
/* End PBXBuildFile section */ | ||
|
||
/* Begin PBXFileReference section */ | ||
C7431F0225F51E1D0094C4CF /* ProjectManager.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ProjectManager.app; sourceTree = BUILT_PRODUCTS_DIR; }; | ||
C7431F0525F51E1D0094C4CF /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; }; | ||
C7431F0725F51E1D0094C4CF /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; }; | ||
C7431F0925F51E1D0094C4CF /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; }; | ||
C7431F0925F51E1D0094C4CF /* MainViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainViewController.swift; sourceTree = "<group>"; }; | ||
C7431F0C25F51E1D0094C4CF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; }; | ||
C7431F0E25F51E1E0094C4CF /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; | ||
C7431F1125F51E1E0094C4CF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; | ||
C7431F1325F51E1E0094C4CF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; | ||
D0293F522ACAB3CE00505749 /* DateFormatManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateFormatManager.swift; sourceTree = "<group>"; }; | ||
D0293F592ACBAA2B00505749 /* Status.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Status.swift; sourceTree = "<group>"; }; | ||
D06DA8E42AC2BA9F00314499 /* Todo.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Todo.xcdatamodel; sourceTree = "<group>"; }; | ||
D06DA8E62AC2BB0D00314499 /* Entity+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Entity+CoreDataClass.swift"; sourceTree = "<group>"; }; | ||
D06DA8E72AC2BB0D00314499 /* Entity+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Entity+CoreDataProperties.swift"; sourceTree = "<group>"; }; | ||
D06DA8EA2AC3B87200314499 /* CoreDataManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreDataManager.swift; sourceTree = SOURCE_ROOT; }; | ||
D09389A72AC20FC5008A8304 /* CollectionReusableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionReusableView.swift; sourceTree = "<group>"; }; | ||
D09389A82AC20FC5008A8304 /* CollectionReusableView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = CollectionReusableView.xib; sourceTree = "<group>"; }; | ||
D0CED7762ABEAB570081ABE2 /* CollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionViewCell.swift; sourceTree = "<group>"; }; | ||
D0CED7772ABEAB570081ABE2 /* CollectionViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = CollectionViewCell.xib; sourceTree = "<group>"; }; | ||
D0CED7802ABEB18D0081ABE2 /* SecondViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecondViewController.swift; sourceTree = "<group>"; }; | ||
/* End PBXFileReference section */ | ||
|
||
/* Begin PBXFrameworksBuildPhase section */ | ||
|
@@ -40,6 +62,8 @@ | |
C7431EF925F51E1D0094C4CF = { | ||
isa = PBXGroup; | ||
children = ( | ||
D06DA8E62AC2BB0D00314499 /* Entity+CoreDataClass.swift */, | ||
D06DA8E72AC2BB0D00314499 /* Entity+CoreDataProperties.swift */, | ||
C7431F0425F51E1D0094C4CF /* ProjectManager */, | ||
C7431F0325F51E1D0094C4CF /* Products */, | ||
); | ||
|
@@ -54,17 +78,82 @@ | |
sourceTree = "<group>"; | ||
}; | ||
C7431F0425F51E1D0094C4CF /* ProjectManager */ = { | ||
isa = PBXGroup; | ||
children = ( | ||
D0293F582ACBAA1D00505749 /* Enum */, | ||
D0CED77F2ABEAEAC0081ABE2 /* Resources */, | ||
D0CED77E2ABEAE800081ABE2 /* Application */, | ||
D0CED77D2ABEAE600081ABE2 /* Controllers */, | ||
D0CED77C2ABEAE520081ABE2 /* ViewModels */, | ||
D0CED77B2ABEAE400081ABE2 /* Views */, | ||
D0CED77A2ABEAE3A0081ABE2 /* Models */, | ||
); | ||
path = ProjectManager; | ||
sourceTree = "<group>"; | ||
}; | ||
D0293F582ACBAA1D00505749 /* Enum */ = { | ||
isa = PBXGroup; | ||
children = ( | ||
D0293F592ACBAA2B00505749 /* Status.swift */, | ||
); | ||
path = Enum; | ||
sourceTree = "<group>"; | ||
}; | ||
D0CED77A2ABEAE3A0081ABE2 /* Models */ = { | ||
isa = PBXGroup; | ||
children = ( | ||
D06DA8EA2AC3B87200314499 /* CoreDataManager.swift */, | ||
); | ||
path = Models; | ||
sourceTree = "<group>"; | ||
}; | ||
D0CED77B2ABEAE400081ABE2 /* Views */ = { | ||
isa = PBXGroup; | ||
children = ( | ||
C7431F0B25F51E1D0094C4CF /* Main.storyboard */, | ||
C7431F1025F51E1E0094C4CF /* LaunchScreen.storyboard */, | ||
D0CED7772ABEAB570081ABE2 /* CollectionViewCell.xib */, | ||
D09389A82AC20FC5008A8304 /* CollectionReusableView.xib */, | ||
); | ||
path = Views; | ||
sourceTree = "<group>"; | ||
}; | ||
D0CED77C2ABEAE520081ABE2 /* ViewModels */ = { | ||
isa = PBXGroup; | ||
children = ( | ||
D0CED7762ABEAB570081ABE2 /* CollectionViewCell.swift */, | ||
D09389A72AC20FC5008A8304 /* CollectionReusableView.swift */, | ||
D0293F522ACAB3CE00505749 /* DateFormatManager.swift */, | ||
); | ||
path = ViewModels; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 뷰모델이 CollectionViewCell,CollectionReusableView,DateFormatManager가 맞나요 ? |
||
sourceTree = "<group>"; | ||
}; | ||
D0CED77D2ABEAE600081ABE2 /* Controllers */ = { | ||
isa = PBXGroup; | ||
children = ( | ||
C7431F0925F51E1D0094C4CF /* MainViewController.swift */, | ||
D0CED7802ABEB18D0081ABE2 /* SecondViewController.swift */, | ||
); | ||
path = Controllers; | ||
sourceTree = "<group>"; | ||
}; | ||
D0CED77E2ABEAE800081ABE2 /* Application */ = { | ||
isa = PBXGroup; | ||
children = ( | ||
C7431F0525F51E1D0094C4CF /* AppDelegate.swift */, | ||
C7431F0725F51E1D0094C4CF /* SceneDelegate.swift */, | ||
C7431F0925F51E1D0094C4CF /* ViewController.swift */, | ||
C7431F0B25F51E1D0094C4CF /* Main.storyboard */, | ||
); | ||
path = Application; | ||
sourceTree = "<group>"; | ||
}; | ||
D0CED77F2ABEAEAC0081ABE2 /* Resources */ = { | ||
isa = PBXGroup; | ||
children = ( | ||
C7431F0E25F51E1E0094C4CF /* Assets.xcassets */, | ||
C7431F1025F51E1E0094C4CF /* LaunchScreen.storyboard */, | ||
C7431F1325F51E1E0094C4CF /* Info.plist */, | ||
D06DA8E32AC2BA9F00314499 /* Todo.xcdatamodeld */, | ||
); | ||
path = ProjectManager; | ||
path = Resources; | ||
sourceTree = "<group>"; | ||
}; | ||
/* End PBXGroup section */ | ||
|
@@ -124,8 +213,10 @@ | |
isa = PBXResourcesBuildPhase; | ||
buildActionMask = 2147483647; | ||
files = ( | ||
D09389AA2AC20FC5008A8304 /* CollectionReusableView.xib in Resources */, | ||
C7431F1225F51E1E0094C4CF /* LaunchScreen.storyboard in Resources */, | ||
C7431F0F25F51E1E0094C4CF /* Assets.xcassets in Resources */, | ||
D0CED7792ABEAB570081ABE2 /* CollectionViewCell.xib in Resources */, | ||
C7431F0D25F51E1D0094C4CF /* Main.storyboard in Resources */, | ||
); | ||
runOnlyForDeploymentPostprocessing = 0; | ||
|
@@ -137,9 +228,18 @@ | |
isa = PBXSourcesBuildPhase; | ||
buildActionMask = 2147483647; | ||
files = ( | ||
C7431F0A25F51E1D0094C4CF /* ViewController.swift in Sources */, | ||
C7431F0A25F51E1D0094C4CF /* MainViewController.swift in Sources */, | ||
D06DA8E52AC2BA9F00314499 /* Todo.xcdatamodeld in Sources */, | ||
C7431F0625F51E1D0094C4CF /* AppDelegate.swift in Sources */, | ||
D06DA8E92AC2BB0D00314499 /* Entity+CoreDataProperties.swift in Sources */, | ||
D0CED7782ABEAB570081ABE2 /* CollectionViewCell.swift in Sources */, | ||
D0293F532ACAB3CE00505749 /* DateFormatManager.swift in Sources */, | ||
D09389A92AC20FC5008A8304 /* CollectionReusableView.swift in Sources */, | ||
D0CED7812ABEB18D0081ABE2 /* SecondViewController.swift in Sources */, | ||
D06DA8E82AC2BB0D00314499 /* Entity+CoreDataClass.swift in Sources */, | ||
D06DA8EB2AC3B87200314499 /* CoreDataManager.swift in Sources */, | ||
C7431F0825F51E1D0094C4CF /* SceneDelegate.swift in Sources */, | ||
D0293F5A2ACBAA2B00505749 /* Status.swift in Sources */, | ||
); | ||
runOnlyForDeploymentPostprocessing = 0; | ||
}; | ||
|
@@ -287,7 +387,7 @@ | |
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | ||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; | ||
CODE_SIGN_STYLE = Automatic; | ||
INFOPLIST_FILE = ProjectManager/Info.plist; | ||
INFOPLIST_FILE = ProjectManager/Resources/Info.plist; | ||
IPHONEOS_DEPLOYMENT_TARGET = 14.1; | ||
LD_RUNPATH_SEARCH_PATHS = ( | ||
"$(inherited)", | ||
|
@@ -306,7 +406,7 @@ | |
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | ||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; | ||
CODE_SIGN_STYLE = Automatic; | ||
INFOPLIST_FILE = ProjectManager/Info.plist; | ||
INFOPLIST_FILE = ProjectManager/Resources/Info.plist; | ||
IPHONEOS_DEPLOYMENT_TARGET = 14.1; | ||
LD_RUNPATH_SEARCH_PATHS = ( | ||
"$(inherited)", | ||
|
@@ -341,6 +441,19 @@ | |
defaultConfigurationName = Release; | ||
}; | ||
/* End XCConfigurationList section */ | ||
|
||
/* Begin XCVersionGroup section */ | ||
D06DA8E32AC2BA9F00314499 /* Todo.xcdatamodeld */ = { | ||
isa = XCVersionGroup; | ||
children = ( | ||
D06DA8E42AC2BA9F00314499 /* Todo.xcdatamodel */, | ||
); | ||
currentVersion = D06DA8E42AC2BA9F00314499 /* Todo.xcdatamodel */; | ||
path = Todo.xcdatamodeld; | ||
sourceTree = "<group>"; | ||
versionGroupType = wrapper.xcdatamodel; | ||
}; | ||
/* End XCVersionGroup section */ | ||
}; | ||
rootObject = C7431EFA25F51E1D0094C4CF /* Project object */; | ||
} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
프로토콜로 지금 하는 crud역할을 나눈다면 어떤 모양이 될까요 ?