# 1.3 woud you please help a beginner from a small pit

**URL:** <https://forums.kodeco.com/t/1-3-woud-you-please-help-a-beginner-from-a-small-pit/141359>\
**Category:** Core Data by Tutorials\
**Created:** [June 2, 2021, 5:08am UTC](https://forums.kodeco.com/t/1-3-woud-you-please-help-a-beginner-from-a-small-pit/141359 "2021-06-02T05:08:08Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![dongri727](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/dongri727/32/81494_2.png) [@dongri727](https://forums.kodeco.com/u/dongri727)\
**Post date:** [June 2, 2021, 5:08am UTC](https://forums.kodeco.com/t/1-3-woud-you-please-help-a-beginner-from-a-small-pit/141359/1 "2021-06-02T05:08:08Z")

</div>

I’m stacked at following part

1.3\*\*\*\* This takes the text in the text field and passes it over to a new method named `save(name:)` . Xcode complains because `save(name:)` doesn’t exist yet. Add the following implementation below `addName(_:)` :

I wrote codes as instructed but Xcode still complains for ‘save(name:)’  
I’m not good at English,Where dose it mean exactly 'below 'addName (\_🙂 '?  
I wrote them at wrong place ?

It worked well before this part  
help me please

//  
// ViewController.swift  
// りすと  
//  
// Created by 押村宙枝 on 30/05/2021.  
//

import UIKit  
import CoreData

var people: [NSManagedObject] = []

class ViewController: UIViewController {

```
@IBOutlet weak var テーブル: UITableView!

var じけん: [String] = []

}

```

extension ViewController: UITableViewDataSource{

```
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    people.count
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    
    let person = people[indexPath.row]
    
    let cell = テーブル.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
    
    cell.textLabel?.text = person.value(forKeyPath: "name") as? String
    return cell
}

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view.
    title = "なにがあった？"
    テーブル.register(UITableViewCell.self,forCellReuseIdentifier: "Cell")
}

@IBAction func ついか(_ sender: UIBarButtonItem){
    
    func save(name: String) {
        
        guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else {
            return
        }
        
        let managedContext = appDelegate.persistentContainer.viewContext
        
        let entity = NSEntityDescription.entity(forEntityName: "Person", in: managedContext)!
        
        let person = NSManagedObject(entity: entity, insertInto: managedContext)
        
        person.setValue(name, forKeyPath: "name")
        
        do {
            try managedContext.save()
            people.append (person)
        } catch let error as NSError {
            print("ほぞんできません. \(error), \(error.userInfo)")
        }
    }
    
    let alert = UIAlertController(title: "しんじじつ", message: "しんじじつついか", preferredStyle: .alert)
    
    
    let saveAction = UIAlertAction(title: "ほぞん", style: .default){
        [unowned self] action in
        
        guard let textField = alert.textFields?.first,
              let nameToSave = textField.text else {
            return
            
        }
        
        self.save(name: nameToSave)
        
        self.テーブル.reloadData()
    }

    
    let とりけし = UIAlertAction(title: "とりけし", style: .cancel)
    
    alert.addTextField()
    
    alert.addAction(saveAction)
    alert.addAction(とりけし)
    
    present(alert, animated: true)
    
    
    
}

```

}

---

<div class="post-metadata">

**Author:** ![pantsz](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/pantsz/32/110937_2.png) [@pantsz](https://forums.kodeco.com/u/pantsz)\
**Post date:** [June 2, 2021, 1:18pm UTC](https://forums.kodeco.com/t/1-3-woud-you-please-help-a-beginner-from-a-small-pit/141359/2 "2021-06-02T13:18:10Z")

</div>

the save(name:) function should be below addName(\_🙂 function, not inside it.

So,

> ```
> func save(name: String) {
> ...
> }
> 
> ```

should be below:

> @IBAction func ついか(\_ sender: UIBarButtonItem){  
> …  
> present(alert, animated: true)  
> }

In this situation, I think you can check out the “final” project included in the Supporting Materials

---

<div class="post-metadata">

**Author:** ![dongri727](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/dongri727/32/81494_2.png) [@dongri727](https://forums.kodeco.com/u/dongri727)\
**Post date:** [June 2, 2021, 2:19pm UTC](https://forums.kodeco.com/t/1-3-woud-you-please-help-a-beginner-from-a-small-pit/141359/3 "2021-06-02T14:19:17Z")

</div>

Hi Pantsz thank you for your reply

below, not inside,  
so after ‘}’ of addName (){}

I’ll try it and report the result  
see you later

---

<div class="post-metadata">

**Author:** ![dongri727](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/dongri727/32/81494_2.png) [@dongri727](https://forums.kodeco.com/u/dongri727)\
**Post date:** [June 3, 2021, 12:00am UTC](https://forums.kodeco.com/t/1-3-woud-you-please-help-a-beginner-from-a-small-pit/141359/4 "2021-06-03T00:00:16Z")

</div>

Hello pantsz

I moved 'func save(name) ’ outside and below ‘func addName(ついか)’  
and it works.

but new problem,it maybe the thing you expected

\*\*_**Could not generate sources: The operation couldn’t be completed. (IDEFoundation.IDETemplateParseError error 1.) [0]**_

what did you see (or not find) in my code ?  
What did you mean  
\*_ **the “final” project included in the Supporting Materials** _  
?

I appreciate your help with this situation.

---

<div class="post-metadata">

**Author:** ![pantsz](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/pantsz/32/110937_2.png) [@pantsz](https://forums.kodeco.com/u/pantsz)\
**Post date:** [June 3, 2021, 11:42am UTC](https://forums.kodeco.com/t/1-3-woud-you-please-help-a-beginner-from-a-small-pit/141359/5 "2021-06-03T11:42:49Z")

</div>

![Screenshot 2021-06-03 at 7.29.31 PM](https://files.chunter.kodeco.com/original/3X/4/7/47723b48a24c27c3884e39f6a8c91500cdb1525d.png)

In the book’s front page, click the “Download Supporting Materials” button, and you can find all the supporting materials divided by chapter, in each chapter’s folder, there is a “final” folder, which contains the “finished” project of that chapter. Comparing your code with that project may help when you have problems.

About the error, I am afraid I don’t know what cause it. In this situation, I will try to goggle the error message and hopefully find some information to solve it.

---

<div class="post-metadata">

**Author:** ![dongri727](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/dongri727/32/81494_2.png) [@dongri727](https://forums.kodeco.com/u/dongri727)\
**Post date:** [June 3, 2021, 12:13pm UTC](https://forums.kodeco.com/t/1-3-woud-you-please-help-a-beginner-from-a-small-pit/141359/6 "2021-06-03T12:13:01Z")

</div>

thank you pantsz, i found the ‘final’ !  
now i have to search my error !  
I’ll inform you the result.

thank you sooooooo much  
hava a nice day !

---

<div class="post-metadata">

**Author:** ![gdelarosa](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/gdelarosa/32/109063_2.png) [@gdelarosa](https://forums.kodeco.com/u/gdelarosa)\
**Post date:** [June 3, 2021, 3:37pm UTC](https://forums.kodeco.com/t/1-3-woud-you-please-help-a-beginner-from-a-small-pit/141359/7 "2021-06-03T15:37:58Z")

</div>

Hi and welcome to the forum community @dongri727! Looks like you were able to resolve your issue which is great. If you have further questions please don’t hesitate to ask here or feel free to join the official Ray Wenderlich Discord chat - [Discord](https://discord.gg/64WqBkfX)

Best,  
Gina

---

<div class="post-metadata">

**Author:** ![dongri727](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/dongri727/32/81494_2.png) [@dongri727](https://forums.kodeco.com/u/dongri727)\
**Post date:** [June 4, 2021, 12:32am UTC](https://forums.kodeco.com/t/1-3-woud-you-please-help-a-beginner-from-a-small-pit/141359/8 "2021-06-04T00:32:48Z")

</div>

Hi gdelarosa, thank you for your message.  
I’m on a very first step of cording, i want to make DB for studying History.  
So i started with this book, but i need some more basic study.  
anyway thank you, i must ask you some help soon.

---

<div class="post-metadata">

**Author:** ![dongri727](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/dongri727/32/81494_2.png) [@dongri727](https://forums.kodeco.com/u/dongri727)\
**Post date:** [June 4, 2021, 2:24am UTC](https://forums.kodeco.com/t/1-3-woud-you-please-help-a-beginner-from-a-small-pit/141359/9 "2021-06-04T02:24:39Z")

</div>

I think that my error caused the name of file.  
I’m a Japanese and named projects with our own letters.  
It seems not good for core data file so i’ve tried to rename it  
but I failed and lost my files.

so I’ll rebuild it in english letters,it must be a good lesson for me.

---

<div class="post-metadata">

**Author:** ![dongri727](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/dongri727/32/81494_2.png) [@dongri727](https://forums.kodeco.com/u/dongri727)\
**Post date:** [June 5, 2021, 6:56am UTC](https://forums.kodeco.com/t/1-3-woud-you-please-help-a-beginner-from-a-small-pit/141359/10 "2021-06-05T06:56:05Z")

</div>

pantsz and Gina

thanks for you two, chapter 1 is done.  
I keep going

see you

---

<div class="post-metadata">

**Author:** ![pantsz](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/pantsz/32/110937_2.png) [@pantsz](https://forums.kodeco.com/u/pantsz)\
**Post date:** [June 5, 2021, 12:50pm UTC](https://forums.kodeco.com/t/1-3-woud-you-please-help-a-beginner-from-a-small-pit/141359/11 "2021-06-05T12:50:23Z")

</div>

Hey, congratulations!

If you are just starting coding, you may want to check out the Swift Apprentice book first, it teach you the programming language, then try UIKit Apprentice or SwiftUI Apprentice(pick one of it). I read UIKit Apprentice when I was a beginner, I remember it cover a bit of CoreData too.

I never read SwiftUI Apprentice, but I think it is like UIKit Apprentice but using newer framework to build UI, they are for beginner too.

For this Core Data book, I think if you finished chapter 4 or 5 and understand everything, you can probably handle the DB of a simple app already.

---

<div class="post-metadata">

**Author:** ![lisukovigor492](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/lisukovigor492/32/81494_2.png) [@lisukovigor492](https://forums.kodeco.com/u/lisukovigor492)\
**Post date:** [June 7, 2021, 2:23pm UTC](https://forums.kodeco.com/t/1-3-woud-you-please-help-a-beginner-from-a-small-pit/141359/12 "2021-06-07T14:23:24Z")

</div>

> [@dongri727](#):
>
> I think that my error caused the name of file.  
> I’m a Japanese and named projects with our own letters.  
> It seems not good for core data file so i’ve tried to rename it  
> but I failed and lost my files.
> 
> so I’ll rebuild it in english letters,it must be a good lesson for me

can you recover your files afterwards?  
if my files disappeared, I wouldn’t react so calmly, uh

---

<div class="post-metadata">

**Author:** ![dongri727](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/dongri727/32/81494_2.png) [@dongri727](https://forums.kodeco.com/u/dongri727)\
**Post date:** [June 7, 2021, 10:54pm UTC](https://forums.kodeco.com/t/1-3-woud-you-please-help-a-beginner-from-a-small-pit/141359/13 "2021-06-07T22:54:06Z")

</div>

hi lisukovigor,  
off course i wasn’t calm , i kicked the cat and the dog and everything  
but it’s not job with appointed day of delivery  
i’m studying so if i wrote them twice, i learned them better.  
good lesson of coding also english for me.  
moreover, chapter 1 is a short one.

finally, i could clear that mission !

---

<div class="post-metadata">

**Author:** ![lisukovigor492](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/lisukovigor492/32/81494_2.png) [@lisukovigor492](https://forums.kodeco.com/u/lisukovigor492)\
**Post date:** [June 15, 2021, 3:00pm UTC](https://forums.kodeco.com/t/1-3-woud-you-please-help-a-beginner-from-a-small-pit/141359/14 "2021-06-15T15:00:09Z")

</div>

I think that my error caused the name of file.  
I’m a Japanese and named [employee time tracking software](https://www.worktime.com/employee-time-tracking-software) projects with our own letters.  
It seems not good for core data file so i’ve tried to rename it  
but I failed and lost my files.

so I’ll rebuild it in english letters,it must be a good lesson for me

eh, I’m happy for you.  
Thank you

---

<div class="post-metadata">

**Author:** ![system](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@system](https://forums.kodeco.com/u/system)\
**Post date:** [November 15, 2021, 9:08pm UTC](https://forums.kodeco.com/t/1-3-woud-you-please-help-a-beginner-from-a-small-pit/141359/15 "2021-11-15T21:08:10Z")

</div>

This topic was automatically closed after 166 days. New replies are no longer allowed.
