2

Assume I have two classes:

class House:NSManagedObject {
  @NSManaged var name: String?
  @NSManaged var window: Window?
}

class Window:NSManagedObject {
  @NSManaged var width: Double
  @NSManaged var height: Double
  @NSManaged var house: House
} 

As you can see there is a to-one relationship between house and window. My question if I have an NSFetchedResultsController instance declared like so

lazy var postsResultsController: NSFetchedResultsController = {
    // Initialize Fetch Request
    let fetchRequest = NSFetchRequest(entityName: "House")

    // Add Sort Descriptors
    let sortDescriptor = NSSortDescriptor(key: "name", ascending: false)
    fetchRequest.sortDescriptors = [sortDescriptor]

    // Initialize Fetched Results Controller
    let fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: StateControl.managedObjectContext, sectionNameKeyPath: nil, cacheName: nil)

    // Configure Fetched Results Controller
    fetchedResultsController.delegate = self

    return fetchedResultsController
  }()

Then will my controller be notified if I have a House with a window, and that window's height or width changes?

Quantaliinuxite
  • 3,133
  • 4
  • 18
  • 32
  • The answer is "No", see http://stackoverflow.com/questions/7533849/nsfetchedresultscontroller-with-relationship-not-updating. – Martin R Feb 25 '16 at 15:53
  • The technology hasn't evolved since 2011? The reason why I'm asking is precisely because there are no up to date answers. – Quantaliinuxite Feb 25 '16 at 15:54
  • If you knew of that answer then you could have mentioned that :) – As far as I know, this hasn't changed. I am pretty sure that Marcus S. Zarra (who is *the* Core Data expert) would have updated his answer otherwise, but you could leave a comment and ask him if he knows of any improvements in that case. Note that the latest comments are from Feb 2015. – Martin R Feb 25 '16 at 15:57
  • Btw, I assume that you meant `NSFetchRequest(entityName: "House")` ? – Martin R Feb 25 '16 at 15:58
  • Yes sorry I'll edit that. You're right I hadn't noticed that the comments dated from 2015. I guess I'll just write my own watcher. – Quantaliinuxite Feb 25 '16 at 16:00

0 Answers0