title: Swift: CoreData call to specific object ID
body: <p>I'm discovering new concepts as a fresh developer, I have been trying to understand core data, and run into an issue with a tutorial I've been walking through. I am getting an error when I call an item using the Object ID. The error is - <strong>Type 'Person.Type' has no subscript members.</strong> it may be because I am just not doing it correctly, or some other reason. I'm sure someone can shine some light on the subject</p>
  
  <h2>Here is a function I wrote to get a specific item out of the Data Stack,</h2>
  
  <pre><code>func getObjectById(id: NSManagedObjectID) -&gt; Person?{
      return context.objectWithID(id) as? Person
  }
  </code></pre>
  
  <h2>Here is how I am calling the function</h2>
  
  <pre><code>func callFirstObject(){
      let context = (UIApplication.sharedApplication().delegate as! AppDelegate).managedObjectContext
      let personService = PersonService(context: context)
  
      let firstPerson = personService.getObjectById(Person[0].objectID!)
  }
  </code></pre>
  
  <p>and from there I am just calling <code>callFirstObject()</code> inside a button.</p>
  
  <p>Edit: I have a function to call all of my objects</p>
  
  <pre><code>func getAllObjects() -&gt; [Person]{
      return getObject(withPredicate: NSPredicate(value: true))
  }
  </code></pre>
  
  <p>and a function to call all of my objects with a predicate </p>
  
  <pre><code>func getObject(withPredicate queryPredicate: NSPredicate) -&gt; [Person]{
      let fetchRequest = NSFetchRequest(entityName: Person.entityName)
  
      fetchRequest.predicate = queryPredicate
      do {
          let response = try context.executeFetchRequest(fetchRequest)
          print("\(response)")
          return response as! [Person]
      } catch let error as NSError {
          // In case of failure
          print("There was an error - \(error)")
          return [Person]()
  
      }
  }
  </code></pre>
  
  <p>I am just trying to call a specific name in the stack.</p>
  
  <p>If more information is needed, I am glad to provide. </p>