Subclass.fetchRequest() Swift 3.0, extension not really helping 100%?

The reason this is happening is there are two methods named fetchRequest in your Person class:

  • first is in your model subclass (Person) with return type NSFetchRequest<Person>
  • second is in NSManagedObject with return type NSFetchRequest<NSFetchRequestResult>

That’s actually why it is ambiguous, compiler does not know which out of 2 you refer to. If you rename func name in your Person+CoreDataProperties to from fetchRequest to personFetchRequest and call by that name – it would compile just like that.

Even better – just add another func to your Person+CoreDataClass with different name, which would return Person.fetchRequest(), and you won’t need to cast when calling by that name.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)