{"id":766,"date":"2020-01-15T13:40:00","date_gmt":"2020-01-15T04:40:00","guid":{"rendered":"https:\/\/www.elehobby.fun\/?p=766"},"modified":"2020-01-15T13:40:00","modified_gmt":"2020-01-15T04:40:00","slug":"swiftno5-beginning-ios13-app-development","status":"publish","type":"post","link":"https:\/\/www.7crystalsky.com\/?p=766","title":{"rendered":"Swift\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30ebNo.5 Beginning iOS13&#038;Swift App Development"},"content":{"rendered":"<div class=\"veu_autoEyeCatchBox\"><img loading=\"lazy\" decoding=\"async\" width=\"487\" height=\"1024\" src=\"https:\/\/www.7crystalsky.com\/wp-content\/uploads\/2020\/01\/25E3258225B925E3258225AF25E3258325AA25E3258325BC25E3258325B325E3258225B725E3258325A725E32583258325E3258325882B2020-01-152B22.29.48-487x1024.png\" class=\"attachment-large size-large wp-post-image\" alt=\"\" srcset=\"https:\/\/www.7crystalsky.com\/wp-content\/uploads\/2020\/01\/25E3258225B925E3258225AF25E3258325AA25E3258325BC25E3258325B325E3258225B725E3258325A725E32583258325E3258325882B2020-01-152B22.29.48-487x1024.png 487w, https:\/\/www.7crystalsky.com\/wp-content\/uploads\/2020\/01\/25E3258225B925E3258225AF25E3258325AA25E3258325BC25E3258325B325E3258225B725E3258325A725E32583258325E3258325882B2020-01-152B22.29.48-143x300.png 143w, https:\/\/www.7crystalsky.com\/wp-content\/uploads\/2020\/01\/25E3258225B925E3258225AF25E3258325AA25E3258325BC25E3258325B325E3258225B725E3258325A725E32583258325E3258325882B2020-01-152B22.29.48-252x530.png 252w, https:\/\/www.7crystalsky.com\/wp-content\/uploads\/2020\/01\/25E3258225B925E3258225AF25E3258325AA25E3258325BC25E3258325B325E3258225B725E3258325A725E32583258325E3258325882B2020-01-152B22.29.48-269x565.png 269w, https:\/\/www.7crystalsky.com\/wp-content\/uploads\/2020\/01\/25E3258225B925E3258225AF25E3258325AA25E3258325BC25E3258325B325E3258225B725E3258325A725E32583258325E3258325882B2020-01-152B22.29.48-338x710.png 338w, https:\/\/www.7crystalsky.com\/wp-content\/uploads\/2020\/01\/25E3258225B925E3258225AF25E3258325AA25E3258325BC25E3258325B325E3258225B725E3258325A725E32583258325E3258325882B2020-01-152B22.29.48-345x725.png 345w, https:\/\/www.7crystalsky.com\/wp-content\/uploads\/2020\/01\/25E3258225B925E3258225AF25E3258325AA25E3258325BC25E3258325B325E3258225B725E3258325A725E32583258325E3258325882B2020-01-152B22.29.48.png 718w\" sizes=\"auto, (max-width: 487px) 100vw, 487px\" \/><\/div>\n<div class=\"separator\" style=\"clear: both; text-align: center;\"><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" border=\"0\" data-original-height=\"1510\" data-original-width=\"718\" height=\"320\" src=\"https:\/\/hobby.7crystalsky.com\/wp-content\/uploads\/2020\/01\/25E3258225B925E3258225AF25E3258325AA25E3258325BC25E3258325B325E3258225B725E3258325A725E32583258325E3258325882B2020-01-152B22.29.48.png\" width=\"152\">&nbsp;\u4eca\u56de\u306f\u3001Chapter4&nbsp; ToDoList using CoreData\u3067\u3059\u3002<br \/>\n\u3053\u306e\u753b\u9762\u306f\u3001\u5165\u529b\u753b\u9762\u3067\u512a\u5148\u9806\u4f4d\u3092\u3064\u3051\u3089\u308c\u307e\u3059\u3002<br \/>\n\u5165\u529b\u5f8c\u306f\u3001TableView\u306b\u30ea\u30b9\u30c8\u8868\u793a\u3055\u308c\u3001\u30ea\u30b9\u30c8\u3092\u6307\u5b9a\u3057\u3066\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u8a73\u7d30\u753b\u9762\u306b\u9077\u79fb\u3057\u307e\u3059\u3002<br \/>\n\u6b21\u56de\u306f\u3001ToDoList\u306b\u5199\u771f\u3092\u8ffd\u52a0\u3059\u308b\u3053\u3068\u306b\u6311\u6226\u3057\u307e\u3059\u3002<\/p>\n<div class=\"separator\" style=\"clear: both; text-align: center;\"><\/div>\n<div class=\"separator\" style=\"clear: both; text-align: center;\"><\/div>\n<div class=\"separator\" style=\"clear: both; text-align: center;\"><\/div>\n<div class=\"p1\"><\/div>\n<div class=\"p2\">\n\/\/<span class=\"Apple-converted-space\">&nbsp; <\/span>ToDoTableViewController.swift<\/div>\n<div class=\"p2\">\n\/\/<span class=\"Apple-converted-space\">&nbsp; <\/span>ToDoList2<\/div>\n<div class=\"p2\"><\/div>\n<div class=\"p3\">\n<span class=\"s1\">import<\/span> UIKit<\/div>\n<div class=\"p1\"><\/div>\n<div class=\"p4\">\n<span class=\"s1\">class<\/span><span class=\"s2\"> <\/span>ToDoTableViewController<span class=\"s2\">: <\/span><span class=\"s3\">UITableViewController<\/span><span class=\"s2\"> {<\/span><\/div>\n<div class=\"p1\">\n<span class=\"Apple-converted-space\">&nbsp;&nbsp; &nbsp;<\/span><\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; <\/span><span class=\"s1\">var<\/span> <span class=\"s4\">toDoCDs<\/span>:[<span class=\"s3\">ToDoCD<\/span>] = []<\/div>\n<div class=\"p1\"><\/div>\n<div class=\"p1\"><\/div>\n<div class=\"p5\">\n<span class=\"s2\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; <\/span><\/span>override<span class=\"s2\"> <\/span>func<span class=\"s2\"> <\/span><span class=\"s4\">viewDidLoad<\/span><span class=\"s2\">() {<\/span><\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"s1\">super<\/span>.viewDidLoad()<\/div>\n<div class=\"p1\"><\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; <\/span>}<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; <\/span><span class=\"s1\">override<\/span> <span class=\"s1\">func<\/span> <span class=\"s4\">viewWillAppear<\/span>(<span class=\"s1\">_<\/span> animated: <span class=\"s3\">Bool<\/span>) {<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <\/span>getToDos()<\/div>\n<div class=\"p1\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp;<\/span><\/div>\n<div class=\"p3\">\n}<\/div>\n<div class=\"p3\"><\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp;<\/span><span class=\"s1\">func<\/span> <span class=\"s4\">getToDos<\/span>(){<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"s1\">if<\/span> <span class=\"s1\">let<\/span> context = (UIApplication.shared.delegate <span class=\"s1\">as<\/span>? <span class=\"s3\">AppDelegate<\/span>)?.persistentContainer.viewContext {<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"s1\">if<\/span> <span class=\"s1\">let<\/span> toDosFromCoreData = <span class=\"s1\">try<\/span>? context.fetch(ToDoCD.fetchRequest()){<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"s1\">if<\/span> <span class=\"s1\">let<\/span> toDos = toDosFromCoreData <span class=\"s1\">as<\/span>? [<span class=\"s3\">ToDoCD<\/span>]{<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <\/span>toDoCDs = toDos<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <\/span>tableView.reloadData()<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <\/span>}<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <\/span>}<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>}<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; <\/span>}<\/div>\n<div class=\"p1\">\n<span class=\"Apple-converted-space\">&nbsp;&nbsp; &nbsp;<\/span><\/div>\n<div class=\"p1\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp;<\/span><\/div>\n<div class=\"p1\">\n<span class=\"Apple-converted-space\">&nbsp;&nbsp; &nbsp;<\/span><\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; <\/span><span class=\"s1\">override<\/span> <span class=\"s1\">func<\/span> <span class=\"s4\">tableView<\/span>(<span class=\"s1\">_<\/span> tableView: <span class=\"s3\">UITableView<\/span>, didSelectRowAt indexPath: <span class=\"s3\">IndexPath<\/span>){<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; <\/span><span class=\"s1\">let<\/span> selectedToDo = toDoCDs[indexPath.row]<\/div>\n<div class=\"p1\">\n<span class=\"Apple-converted-space\">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<\/span><\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>performSegue(withIdentifier: <span class=\"s5\">&#8220;moveToDetails&#8221;<\/span>, sender: selectedToDo)<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; <\/span>}<\/div>\n<div class=\"p1\"><\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; <\/span><span class=\"s1\">override<\/span> <span class=\"s1\">func<\/span> <span class=\"s4\">tableView<\/span>(<span class=\"s1\">_<\/span> tableView: <span class=\"s3\">UITableView<\/span>, numberOfRowsInSection section: <span class=\"s3\">Int<\/span>) -&gt; <span class=\"s3\">Int<\/span> {<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"s1\">return<\/span> toDoCDs.count<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; <\/span>}<\/div>\n<div class=\"p1\"><\/div>\n<div class=\"p1\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp;<\/span><\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; <\/span><span class=\"s1\">override<\/span> <span class=\"s1\">func<\/span> <span class=\"s4\">tableView<\/span>(<span class=\"s1\">_<\/span> tableView: <span class=\"s3\">UITableView<\/span>, cellForRowAt indexPath: <span class=\"s3\">IndexPath<\/span>) -&gt; <span class=\"s3\">UITableViewCell<\/span> {<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"s1\">let<\/span> cell = UITableViewCell()<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"s1\">let<\/span> selectedToDo = toDoCDs[indexPath.row]<\/div>\n<div class=\"p1\">\n<span class=\"Apple-converted-space\">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<\/span><\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"s1\">if<\/span> selectedToDo.priority == <span class=\"s6\">1<\/span><span class=\"Apple-converted-space\">&nbsp; &nbsp; <\/span>{<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"s1\">if<\/span> <span class=\"s1\">let<\/span> name = selectedToDo.name{<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <\/span>cell.textLabel?.text = <span class=\"s5\">&#8220;\u2757\ufe0f&#8221;<\/span> + name<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <\/span>}<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>}<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"s1\">else<\/span> <span class=\"s1\">if<\/span> selectedToDo.priority == <span class=\"s6\">2<\/span>{<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"s1\">if<\/span> <span class=\"s1\">let<\/span> name = selectedToDo.name{<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <\/span>cell.textLabel?.text = <span class=\"s5\">&#8220;\u203c\ufe0f&#8221;<\/span> + name<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <\/span>}<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>}<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"s1\">else<\/span> {<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"s1\">if<\/span> <span class=\"s1\">let<\/span> name = selectedToDo.name{<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <\/span>cell.textLabel?.text = name<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>}<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>}<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"s1\">return<\/span> cell<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; <\/span>}<\/div>\n<div class=\"p1\"><\/div>\n<div class=\"p1\"><\/div>\n<div class=\"p1\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<\/span><\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp;&nbsp; &nbsp; &nbsp; <\/span><span class=\"s1\">override<\/span> <span class=\"s1\">func<\/span> <span class=\"s4\">prepare<\/span>(for segue: <span class=\"s3\">UIStoryboardSegue<\/span>, sender: <span class=\"s1\">Any<\/span>?) {<\/div>\n<div class=\"p1\">\n<span class=\"Apple-converted-space\">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<\/span><\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"s1\">if<\/span> <span class=\"s1\">let<\/span> addToDoViewController = segue.destination <span class=\"s1\">as<\/span>?<\/div>\n<div class=\"p7\">\n<span class=\"s2\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <\/span><\/span>AddToDoViewController<span class=\"s2\">{<\/span><\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <\/span>addToDoViewController.toDoTableViewController = <span class=\"s1\">self<\/span><\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>}<\/div>\n<div class=\"p1\">\n<span class=\"Apple-converted-space\">&nbsp;&nbsp; &nbsp;<\/span><\/div>\n<div class=\"p1\">\n<span class=\"Apple-converted-space\">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<\/span><\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"s1\">if<\/span> <span class=\"s1\">let<\/span> detailsToDoViewController = segue.destination <span class=\"s1\">as<\/span>?<\/div>\n<div class=\"p7\">\n<span class=\"s2\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <\/span><\/span>ToDoDetailsViewController<span class=\"s2\">{<\/span><\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"s1\">if<\/span> <span class=\"s1\">let<\/span> selectedToDo = sender <span class=\"s1\">as<\/span>? <span class=\"s3\">ToDoCD<\/span>{<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <\/span>detailsToDoViewController.toDoCD = selectedToDo<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <\/span>}<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>}<\/div>\n<div class=\"p3\">\n}<\/div>\n<div class=\"p1\">\n<span class=\"Apple-converted-space\">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<\/span><\/div>\n<div class=\"p3\">\n}<\/div>\n<style type=\"text\/css\">\np.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #000000; color: rgba(0, 0, 0, 0.85); background-color: #ffffff; min-height: 21.0px}<br \/>\np.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #5d6c79; background-color: #ffffff}<br \/>\np.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #000000; color: rgba(0, 0, 0, 0.85); background-color: #ffffff}<br \/>\np.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #0b4f79; background-color: #ffffff}<br \/>\np.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #9b2393; background-color: #ffffff}<br \/>\np.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #4a5560; background-color: #ffffff}<br \/>\np.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #3900a0; background-color: #ffffff}<br \/>\nspan.s1 {color: #9b2393}<br \/>\nspan.s2 {color: rgba(0, 0, 0, 0.85)}<br \/>\nspan.s3 {color: #3900a0}<br \/>\nspan.s4 {color: #0f68a0}<br \/>\nspan.s5 {color: #c41a16}<br \/>\nspan.s6 {color: #1c00cf}<br \/>\nspan.s7 {color: #5d6c79}<br \/>\n<\/style>\n<p><!-- more --><\/p>\n<style type=\"text\/css\">\np.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #000000; color: rgba(0, 0, 0, 0.85); background-color: #ffffff; min-height: 21.0px}<br \/>\np.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #5d6c79; background-color: #ffffff}<br \/>\np.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #000000; color: rgba(0, 0, 0, 0.85); background-color: #ffffff}<br \/>\np.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #0b4f79; background-color: #ffffff}<br \/>\np.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #9b2393; background-color: #ffffff}<br \/>\np.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #6c36a9; background-color: #ffffff}<br \/>\nspan.s1 {color: #9b2393}<br \/>\nspan.s2 {color: rgba(0, 0, 0, 0.85)}<br \/>\nspan.s3 {color: #3900a0}<br \/>\nspan.s4 {color: #0f68a0}<br \/>\nspan.s5 {color: #1c464a}<br \/>\nspan.s6 {color: #6c36a9}<br \/>\nspan.s7 {color: #326d74}<br \/>\nspan.s8 {color: #1c00cf}<br \/>\nspan.s9 {color: #c41a16}<br \/>\n<\/style>\n<div class=\"p1\"><\/div>\n<div class=\"p2\">\n\/\/<span class=\"Apple-converted-space\">&nbsp; <\/span>ToDoDetailsViewController.swift<\/div>\n<div class=\"p2\">\n\/\/<span class=\"Apple-converted-space\">&nbsp; <\/span>ToDoList2<\/div>\n<div class=\"p2\"><\/div>\n<div class=\"p1\"><\/div>\n<div class=\"p3\">\n<span class=\"s1\">import<\/span> UIKit<\/div>\n<div class=\"p1\"><\/div>\n<div class=\"p4\">\n<span class=\"s1\">class<\/span><span class=\"s2\"> <\/span>ToDoDetailsViewController<span class=\"s2\">: <\/span><span class=\"s3\">UIViewController<\/span><span class=\"s2\"> {<\/span><\/div>\n<div class=\"p1\"><\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; <\/span><span class=\"s1\">var<\/span> <span class=\"s4\">toDoCD<\/span>:<span class=\"s5\">ToDoCD<\/span>? = <span class=\"s1\">nil<\/span><\/div>\n<div class=\"p1\">\n<span class=\"Apple-converted-space\">&nbsp;&nbsp; &nbsp;<\/span><\/div>\n<div class=\"p5\">\n<span class=\"s2\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; <\/span><\/span>@IBOutlet<span class=\"s2\"> <\/span>weak<span class=\"s2\"> <\/span>var<span class=\"s2\"> <\/span><span class=\"s4\">toDoLabel<\/span><span class=\"s2\">: <\/span><span class=\"s3\">UILabel<\/span><span class=\"s2\">!<\/span><\/div>\n<div class=\"p1\">\n<span class=\"Apple-converted-space\">&nbsp;&nbsp; &nbsp;<\/span><\/div>\n<div class=\"p5\">\n<span class=\"s2\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; <\/span><\/span>override<span class=\"s2\"> <\/span>func<span class=\"s2\"> <\/span><span class=\"s4\">viewDidLoad<\/span><span class=\"s2\">() {<\/span><\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"s1\">super<\/span>.<span class=\"s6\">viewDidLoad<\/span>()<\/div>\n<div class=\"p1\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp;<\/span><\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"s1\">if<\/span> <span class=\"s1\">let<\/span> toDo = <span class=\"s7\">toDoCD<\/span>{<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"s1\">if<\/span> toDo.<span class=\"s7\">priority<\/span> <span class=\"s6\">==<\/span> <span class=\"s8\">1<\/span>{<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"s1\">if<\/span> <span class=\"s1\">let<\/span> name = toDo.<span class=\"s7\">name<\/span>{<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"s7\">toDoLabel<\/span>.<span class=\"s6\">text<\/span> = <span class=\"s9\">&#8220;\u2757\ufe0f&#8221;<\/span> <span class=\"s6\">+<\/span> name<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>}<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; <\/span>}<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"s1\">else<\/span> <span class=\"s1\">if<\/span> toDo.<span class=\"s7\">priority<\/span> <span class=\"s6\">==<\/span> <span class=\"s8\">2<\/span>{<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; <\/span><span class=\"s1\">if<\/span> <span class=\"s1\">let<\/span> name = toDo.<span class=\"s7\">name<\/span>{<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"s7\">toDoLabel<\/span>.<span class=\"s6\">text<\/span> = <span class=\"s9\">&#8220;\u203c\ufe0f&#8221;<\/span> <span class=\"s6\">+<\/span> name<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <\/span>}<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>}<span class=\"s1\">else<\/span>{<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"s1\">if<\/span> toDo.<span class=\"s7\">name<\/span> <span class=\"s6\">!=<\/span> <span class=\"s1\">nil<\/span>{<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"s7\">toDoLabel<\/span>.<span class=\"s6\">text<\/span> = toDo.<span class=\"s7\">name<\/span><\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>}<\/div>\n<div class=\"p2\">\n<span class=\"s2\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><\/span>\/\/ Do any additional setup after loading the view.<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; <\/span>}<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>}<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; <\/span>}<\/div>\n<div class=\"p1\">\n<span class=\"Apple-converted-space\">&nbsp;&nbsp; &nbsp;<\/span><\/div>\n<div class=\"p1\"><\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; <\/span><span class=\"s1\">@IBAction<\/span> <span class=\"s1\">func<\/span> <span class=\"s4\">doneTapped<\/span>(<span class=\"s1\">_<\/span> sender: <span class=\"s1\">Any<\/span>) {<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"s1\">if<\/span> <span class=\"s1\">let<\/span> context = (<span class=\"s3\">UIApplication<\/span>.<span class=\"s6\">shared<\/span>.<span class=\"s6\">delegate<\/span> <span class=\"s1\">as<\/span>? <span class=\"s5\">AppDelegate<\/span>)?.<span class=\"s7\">persistentContainer<\/span>.<span class=\"s6\">viewContext<\/span>{<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"s1\">if<\/span> <span class=\"s1\">let<\/span> toDo = <span class=\"s7\">toDoCD<\/span>{<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <\/span>context.<span class=\"s6\">delete<\/span>(toDo)<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <\/span>}<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <\/span>(<span class=\"s3\">UIApplication<\/span>.<span class=\"s6\">shared<\/span>.<span class=\"s6\">delegate<\/span> <span class=\"s1\">as<\/span>? <span class=\"s5\">AppDelegate<\/span>)?.<span class=\"s7\">saveContext<\/span>()<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>}<\/div>\n<div class=\"p6\">\n<span class=\"s2\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><\/span>navigationController<span class=\"s2\">?.<\/span>popViewController<span class=\"s2\">(animated: <\/span><span class=\"s1\">true<\/span><span class=\"s2\">)<\/span><\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; <\/span>}<\/div>\n<div class=\"p3\">\n}<\/div>\n<div class=\"p3\"><\/div>\n<div class=\"p1\">\n\/\/<span class=\"Apple-converted-space\">&nbsp; <\/span>AddToDoViewController.swift<\/div>\n<div class=\"p1\">\n\/\/<span class=\"Apple-converted-space\">&nbsp; <\/span>ToDoList2<\/div>\n<div class=\"p1\"><\/div>\n<div class=\"p2\"><\/div>\n<div class=\"p3\">\n<span class=\"s1\">import<\/span> UIKit<\/div>\n<div class=\"p2\"><\/div>\n<div class=\"p4\">\n<span class=\"s1\">class<\/span><span class=\"s2\"> <\/span>AddToDoViewController<span class=\"s2\">: <\/span><span class=\"s3\">UIViewController<\/span><span class=\"s2\"> {<\/span><\/div>\n<div class=\"p2\">\n<span class=\"Apple-converted-space\">&nbsp;&nbsp; &nbsp;<\/span><\/div>\n<div class=\"p5\">\n<span class=\"s2\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; <\/span><\/span><span class=\"s1\">var<\/span><span class=\"s2\"> <\/span>toDoTableViewController<span class=\"s2\">:<\/span><span class=\"s3\">ToDoTableViewController<\/span><span class=\"s2\">? = <\/span><span class=\"s1\">nil<\/span><\/div>\n<div class=\"p2\">\n<span class=\"Apple-converted-space\">&nbsp;&nbsp; &nbsp;<\/span><\/div>\n<div class=\"p6\">\n<span class=\"s2\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; <\/span><\/span>@IBOutlet<span class=\"s2\"> <\/span>weak<span class=\"s2\"> <\/span>var<span class=\"s2\"> <\/span><span class=\"s4\">nameTextField<\/span><span class=\"s2\">: <\/span><span class=\"s3\">UITextField<\/span><span class=\"s2\">!<\/span><\/div>\n<div class=\"p7\">\n<span class=\"s2\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; <\/span><\/span><span class=\"s1\">@IBOutlet<\/span><span class=\"s2\"> <\/span><span class=\"s1\">weak<\/span><span class=\"s2\"> <\/span><span class=\"s1\">var<\/span><span class=\"s2\"> <\/span><span class=\"s4\">prioritySegment<\/span><span class=\"s2\">: <\/span>UISegmentedControl<span class=\"s2\">!<\/span><\/div>\n<div class=\"p2\">\n<span class=\"Apple-converted-space\">&nbsp;&nbsp; &nbsp;<\/span><\/div>\n<div class=\"p6\">\n<span class=\"s2\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; <\/span><\/span>override<span class=\"s2\"> <\/span>func<span class=\"s2\"> <\/span><span class=\"s4\">viewDidLoad<\/span><span class=\"s2\">() {<\/span><\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"s1\">super<\/span>.viewDidLoad()<\/div>\n<div class=\"p2\"><\/div>\n<div class=\"p1\">\n<span class=\"s2\"><span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><\/span>\/\/ Do any additional setup after loading the view.<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; <\/span>}<\/div>\n<div class=\"p2\">\n<span class=\"Apple-converted-space\">&nbsp;&nbsp; &nbsp;<\/span><\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; <\/span><span class=\"s1\">@IBAction<\/span> <span class=\"s1\">func<\/span> <span class=\"s4\">addTapped<\/span>(<span class=\"s1\">_<\/span> sender: <span class=\"s1\">Any<\/span>) {<\/div>\n<div class=\"p2\">\n<span class=\"Apple-converted-space\">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<\/span><\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"s1\">if<\/span> <span class=\"s1\">let<\/span> context = (UIApplication.shared.delegate <span class=\"s1\">as<\/span>? <span class=\"s3\">AppDelegate<\/span>)?.persistentContainer.viewContext<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>{<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"s1\">let<\/span> newToDo = ToDoCD(context: context)<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>newToDo.priority = Int32(prioritySegment.selectedSegmentIndex)<\/div>\n<div class=\"p2\">\n<span class=\"Apple-converted-space\">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<\/span><\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <\/span><span class=\"s1\">if<\/span> <span class=\"s1\">let<\/span> name = nameTextField.text{<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <\/span>newToDo.name = name<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>}<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>(UIApplication.shared.delegate <span class=\"s1\">as<\/span>? <span class=\"s3\">AppDelegate<\/span>)?.saveContext()<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>}<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; &nbsp; &nbsp; <\/span>navigationController?.popViewController(animated: <span class=\"s1\">true<\/span>)<\/div>\n<div class=\"p3\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp; <\/span>}<\/div>\n<div class=\"p2\"><\/div>\n<div class=\"p3\">\n<style type=\"text\/css\">\np.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #5d6c79; background-color: #ffffff}<br \/>\np.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #000000; color: rgba(0, 0, 0, 0.85); background-color: #ffffff; min-height: 21.0px}<br \/>\np.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #000000; color: rgba(0, 0, 0, 0.85); background-color: #ffffff}<br \/>\np.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #0b4f79; background-color: #ffffff}<br \/>\np.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #0f68a0; background-color: #ffffff}<br \/>\np.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #9b2393; background-color: #ffffff}<br \/>\np.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #3900a0; background-color: #ffffff}<br \/>\nspan.s1 {color: #9b2393}<br \/>\nspan.s2 {color: rgba(0, 0, 0, 0.85)}<br \/>\nspan.s3 {color: #3900a0}<br \/>\nspan.s4 {color: #0f68a0}<br \/>\nspan.s5 {color: #5d6c79}<br \/>\n<\/style>\n<\/div>\n<div class=\"p3\">\n}<\/div>\n<div class=\"p1\">\n<span class=\"Apple-converted-space\">&nbsp; &nbsp;<\/span><\/div>\n<div class=\"veu_socialSet veu_socialSet-position-after veu_contentAddSection\"><script>window.twttr=(function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],t=window.twttr||{};if(d.getElementById(id))return t;js=d.createElement(s);js.id=id;js.src=\"https:\/\/platform.twitter.com\/widgets.js\";fjs.parentNode.insertBefore(js,fjs);t._e=[];t.ready=function(f){t._e.push(f);};return t;}(document,\"script\",\"twitter-wjs\"));<\/script><ul><li class=\"sb_facebook sb_icon\"><a class=\"sb_icon_inner\" href=\"\/\/www.facebook.com\/sharer.php?src=bm&u=https%3A%2F%2Fwww.7crystalsky.com%2F%3Fp%3D766&amp;t=IT%E3%82%92%E6%A5%BD%E3%81%97%E3%82%80%E4%BC%9A\" target=\"_blank\" onclick=\"window.open(this.href,'FBwindow','width=650,height=450,menubar=no,toolbar=no,scrollbars=yes');return false;\"><span class=\"vk_icon_w_r_sns_fb icon_sns\"><\/span><span class=\"sns_txt\">Facebook<\/span><span class=\"veu_count_sns_fb\"><\/span><\/a><\/li><li class=\"sb_x_twitter sb_icon\"><a class=\"sb_icon_inner\" href=\"\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fwww.7crystalsky.com%2F%3Fp%3D766&amp;text=IT%E3%82%92%E6%A5%BD%E3%81%97%E3%82%80%E4%BC%9A\" target=\"_blank\" ><span class=\"vk_icon_w_r_sns_x_twitter icon_sns\"><\/span><span class=\"sns_txt\">X<\/span><\/a><\/li><\/ul><\/div><!-- [ \/.socialSet ] -->","protected":false},"excerpt":{"rendered":"<p>&nbsp;\u4eca\u56de\u306f\u3001Chapter4&nbsp; ToDoList using CoreData\u3067\u3059\u3002 \u3053\u306e\u753b\u9762\u306f\u3001\u5165\u529b\u753b\u9762\u3067\u512a\u5148\u9806\u4f4d\u3092\u3064\u3051\u3089\u308c\u307e\u3059\u3002 \u5165\u529b\u5f8c\u306f\u3001TableView\u306b\u30ea\u30b9\u30c8\u8868\u793a\u3055\u308c\u3001\u30ea\u30b9\u30c8\u3092\u6307\u5b9a\u3057\u3066\u30af\u30ea\u30c3 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":42,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"vkexunit_cta_each_option":"","footnotes":""},"categories":[49,22,50,32],"tags":[7,8],"class_list":["post-766","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mac","category-swift","category-xcode","category-32","tag-swift5ios13","tag-xcode11"],"_links":{"self":[{"href":"https:\/\/www.7crystalsky.com\/index.php?rest_route=\/wp\/v2\/posts\/766","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.7crystalsky.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.7crystalsky.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.7crystalsky.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.7crystalsky.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=766"}],"version-history":[{"count":0,"href":"https:\/\/www.7crystalsky.com\/index.php?rest_route=\/wp\/v2\/posts\/766\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.7crystalsky.com\/index.php?rest_route=\/wp\/v2\/media\/42"}],"wp:attachment":[{"href":"https:\/\/www.7crystalsky.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=766"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.7crystalsky.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=766"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.7crystalsky.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=766"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}