title: Fetch specific attributes from coredata swift
body: <p>I am developing core data in my application.
  I want to fetch name attribute from the core data.</p>
  
  <p>class ViewController: UIViewController {</p>
  
  <pre><code>@IBOutlet weak var saveDataBtn:UIButton!
  @IBOutlet weak var dataTxtField:UITextField!
  @IBOutlet weak var dataLbl:UILabel!
  var tasks: [Task] = []
  let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
  
  @IBAction func saveDataBtnPressed(_sender : UIButton){
      print("Save Data.")
      let task = Task(context: context)
      task.name = dataTxtField.text
      (UIApplication.shared.delegate as! AppDelegate).saveContext()
      getData()
  }
  
  func getData(){
      do{
          tasks = try context.fetch(Task.fetchRequest())
  
      }catch{
          print("Fetching Failed")
  
      }
  
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/3djGR.png" rel="noreferrer"><img src="https://i.stack.imgur.com/3djGR.png" alt="I am attaching my xcdatamodel"></a></p>
  
  <p>How can i get it?</p>
  
  <p>Thanks,</p>