Error: "-[Photo tags]: unrecognized selector..."



I got this error:

*** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: '-[Photo tags]: unrecognized selector sent to instance 0x61800028ab40"

when I select the “Tags” bar button item in the menu bar of the PhotoInfoViewController.

Using breakpoints and such, I’ve narrowed it down to the tags property of the photo instance. To me it seems like maybe it thinks I’m trying to call a ‘tags’ method on it if I had to guess?

Another guess is it is having trouble handling “tags” constant in my method when it returns nothing since I haven’t created any yet.

This could also be because I failed to use the correct method since I’m using the 5th ed. while translating the code into Swift 3.0.

Here is my updateTags() method:

 func updateTags() {
    let tags = try! store.fetchMainQueueTags(predicate: nil, sortDescriptors: [NSSortDescriptor(key: "name", ascending: true)])
    tagDataSource.tags = tags
    for tag in photo.tags {
        if let index = tagDataSource.tags.index(of: tag) {
            let indexPath = IndexPath(row: index, section: 0)

Here is my fetchMainQueue method:

func fetchMainQueueTags(predicate: NSPredicate? = nil, sortDescriptors: [NSSortDescriptor]? = nil) throws -> [NSManagedObject] {
    let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: "Tag")
    fetchRequest.predicate = predicate
    fetchRequest.sortDescriptors = sortDescriptors
    let mainQueueContext = self.coreDataStack.mainQueueContext
    var mainQueueTags: [NSManagedObject]?
    var fetchRequestError: Error?
    mainQueueContext.performAndWait {
        do {
            mainQueueTags = try mainQueueContext.fetch(fetchRequest) as? [NSManagedObject]
        catch let error {
            fetchRequestError = error
    guard let tags = mainQueueTags else {
        throw fetchRequestError!
    return tags

Thanks in advance!