Skip to content
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

Test #6

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
83 changes: 72 additions & 11 deletions Todoey.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,23 @@
objects = {

/* Begin PBXBuildFile section */
253DFDAB26177B2900FC7E5A /* K.swift in Sources */ = {isa = PBXBuildFile; fileRef = 253DFDAA26177B2900FC7E5A /* K.swift */; };
2589B58D261B9F7500B2CDB6 /* DataModel.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 2589B58B261B9F7500B2CDB6 /* DataModel.xcdatamodeld */; };
25E07C1426207FD80002F188 /* CategoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 25E07C1326207FD80002F188 /* CategoryViewController.swift */; };
EB2BE4FA239524DB00FB933B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB2BE4F9239524DB00FB933B /* AppDelegate.swift */; };
EB2BE4FE239524DB00FB933B /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB2BE4FD239524DB00FB933B /* ViewController.swift */; };
EB2BE4FE239524DB00FB933B /* ToDoListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB2BE4FD239524DB00FB933B /* ToDoListViewController.swift */; };
EB2BE501239524DB00FB933B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EB2BE4FF239524DB00FB933B /* Main.storyboard */; };
EB2BE503239524DC00FB933B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EB2BE502239524DC00FB933B /* Assets.xcassets */; };
EB2BE506239524DC00FB933B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EB2BE504239524DC00FB933B /* LaunchScreen.storyboard */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
253DFDAA26177B2900FC7E5A /* K.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = K.swift; sourceTree = "<group>"; };
2589B58C261B9F7500B2CDB6 /* DataModel.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = DataModel.xcdatamodel; sourceTree = "<group>"; };
25E07C1326207FD80002F188 /* CategoryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CategoryViewController.swift; sourceTree = "<group>"; };
EB2BE4F6239524DB00FB933B /* Todoey.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Todoey.app; sourceTree = BUILT_PRODUCTS_DIR; };
EB2BE4F9239524DB00FB933B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
EB2BE4FD239524DB00FB933B /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
EB2BE4FD239524DB00FB933B /* ToDoListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToDoListViewController.swift; sourceTree = "<group>"; };
EB2BE500239524DB00FB933B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
EB2BE502239524DC00FB933B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
EB2BE505239524DC00FB933B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
Expand All @@ -35,6 +41,42 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
2589B57A261A1F1800B2CDB6 /* Controller */ = {
isa = PBXGroup;
children = (
EB2BE4FD239524DB00FB933B /* ToDoListViewController.swift */,
25E07C1326207FD80002F188 /* CategoryViewController.swift */,
);
path = Controller;
sourceTree = "<group>";
};
2589B57C261A1F1E00B2CDB6 /* View */ = {
isa = PBXGroup;
children = (
EB2BE4FF239524DB00FB933B /* Main.storyboard */,
);
path = View;
sourceTree = "<group>";
};
2589B57E261A1F3F00B2CDB6 /* Supporting Files */ = {
isa = PBXGroup;
children = (
EB2BE502239524DC00FB933B /* Assets.xcassets */,
EB2BE4F9239524DB00FB933B /* AppDelegate.swift */,
253DFDAA26177B2900FC7E5A /* K.swift */,
EB2BE504239524DC00FB933B /* LaunchScreen.storyboard */,
);
path = "Supporting Files";
sourceTree = "<group>";
};
2589B584261A247900B2CDB6 /* Model */ = {
isa = PBXGroup;
children = (
2589B58B261B9F7500B2CDB6 /* DataModel.xcdatamodeld */,
);
path = Model;
sourceTree = "<group>";
};
EB2BE4ED239524DB00FB933B = {
isa = PBXGroup;
children = (
Expand All @@ -54,12 +96,11 @@
EB2BE4F8239524DB00FB933B /* Todoey */ = {
isa = PBXGroup;
children = (
EB2BE4F9239524DB00FB933B /* AppDelegate.swift */,
EB2BE4FD239524DB00FB933B /* ViewController.swift */,
EB2BE4FF239524DB00FB933B /* Main.storyboard */,
EB2BE502239524DC00FB933B /* Assets.xcassets */,
EB2BE504239524DC00FB933B /* LaunchScreen.storyboard */,
EB2BE507239524DC00FB933B /* Info.plist */,
2589B584261A247900B2CDB6 /* Model */,
2589B57C261A1F1E00B2CDB6 /* View */,
2589B57A261A1F1800B2CDB6 /* Controller */,
2589B57E261A1F3F00B2CDB6 /* Supporting Files */,
);
path = Todoey;
sourceTree = "<group>";
Expand Down Expand Up @@ -91,7 +132,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1120;
LastUpgradeCheck = 1120;
LastUpgradeCheck = 1240;
ORGANIZATIONNAME = "App Brewery";
TargetAttributes = {
EB2BE4F5239524DB00FB933B = {
Expand Down Expand Up @@ -135,7 +176,10 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
EB2BE4FE239524DB00FB933B /* ViewController.swift in Sources */,
25E07C1426207FD80002F188 /* CategoryViewController.swift in Sources */,
2589B58D261B9F7500B2CDB6 /* DataModel.xcdatamodeld in Sources */,
253DFDAB26177B2900FC7E5A /* K.swift in Sources */,
EB2BE4FE239524DB00FB933B /* ToDoListViewController.swift in Sources */,
EB2BE4FA239524DB00FB933B /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -188,6 +232,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand Down Expand Up @@ -248,6 +293,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand Down Expand Up @@ -281,13 +327,14 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = BSWZ8YLAG5;
INFOPLIST_FILE = Todoey/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.londonappbrewery.todoey-ios13.Todoey";
PRODUCT_BUNDLE_IDENTIFIER = com.renovatio.todoey;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand All @@ -299,13 +346,14 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = BSWZ8YLAG5;
INFOPLIST_FILE = Todoey/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.londonappbrewery.todoey-ios13.Todoey";
PRODUCT_BUNDLE_IDENTIFIER = com.renovatio.todoey;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down Expand Up @@ -334,6 +382,19 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCVersionGroup section */
2589B58B261B9F7500B2CDB6 /* DataModel.xcdatamodeld */ = {
isa = XCVersionGroup;
children = (
2589B58C261B9F7500B2CDB6 /* DataModel.xcdatamodel */,
);
currentVersion = 2589B58C261B9F7500B2CDB6 /* DataModel.xcdatamodel */;
path = DataModel.xcdatamodeld;
sourceTree = "<group>";
versionGroupType = wrapper.xcdatamodel;
};
/* End XCVersionGroup section */
};
rootObject = EB2BE4EE239524DB00FB933B /* Project object */;
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
uuid = "8FF7B792-2D00-4B41-BC6E-FBD28145C0F6"
type = "1"
version = "2.0">
</Bucket>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>Todoey.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
Binary file added Todoey/.DS_Store
Binary file not shown.
46 changes: 0 additions & 46 deletions Todoey/AppDelegate.swift

This file was deleted.

24 changes: 0 additions & 24 deletions Todoey/Base.lproj/Main.storyboard

This file was deleted.

95 changes: 95 additions & 0 deletions Todoey/Controller/CategoryViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
//
// CategoryViewController.swift
// Todoey
//
// Created by Ran on 09/04/2021.
// Copyright © 2021 App Brewery. All rights reserved.
//

import UIKit
import CoreData

class CategoryViewController: UITableViewController {

var itemArray = [Category]()
let dataFilePath = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first?.appendingPathComponent("Category.plist")
let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext

override func viewDidLoad() {
super.viewDidLoad()

loadCategories()
}



//MARK: - TableViewDataSource Methods

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return itemArray.count
}

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

let category = itemArray[indexPath.row].name
let cell = tableView.dequeueReusableCell(withIdentifier: K.CategoryCell, for: indexPath)

cell.textLabel?.text = category

return cell

}
//
// tableview override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
// performSegue(withIdentifier: <#T##String#>, sender: <#T##Any?#>)
// }


//MARK: - Save and load methods

func saveCategories() {

do {
try context.save()
} catch {
print(error)
}

tableView.reloadData()
}

func loadCategories(with request: NSFetchRequest<Category> = Category.fetchRequest()){

do {
itemArray = try context.fetch(request)
} catch {
print("Error fetching data from Category context \(error)")
}
}

//MARK: - Add a new item
@IBAction func addButtonPressed(_ sender: UIBarButtonItem) {

var textField = UITextField()

let alert = UIAlertController(title: "Add a new category", message: "", preferredStyle: .alert)

alert.addTextField { (alertTextField) in
alertTextField.placeholder = "Create a new category"
textField = alertTextField
}

let action = UIAlertAction(title: "Add Category", style: .default) { (action) in
let newCategory = Category(context: self.context)
newCategory.name = textField.text!
self.itemArray.append(newCategory)
self.saveCategories()
}

alert.addAction(action)
present(alert, animated: true, completion: nil)
}



}
Loading