Mac Core Data hanging when editing NSTextView on a previously saved document

sylvantemplar

macrumors newbie
Original poster
Nov 14, 2011
4
0
Interesting problem here:

I've got a handful of textviews connected to a Core Data model. Everything works fine, except one thing.

When I put information into a textview, the entire application slows to a crawl, invoking the beachball.

When I attached a Core Data Instrument to my app's process, NSManagedObjectContext save is being called with each character that is typed. This lag is crippling the entire application.

To make things stranger, the problem is not consistent. Sometimes the app decides it needs to write to the saved document (SQLite, XML, binary, doesn't matter) for each and every character that is typed into the textview, and other times it won't.

Any ideas?
 

sylvantemplar

macrumors newbie
Original poster
Nov 14, 2011
4
0
Update: after poking around the document implementation file, I saw the class method autoSavesInPlace returning YES. I suspected that this might have something to do with it, and it turns out it did. Something about the managedContext does not like this method to return YES, and feels compelled to perform incremental saves at inappropriate times. Setting this method to return NO completely resolved my issue. It's worth noting that this method is defaulted to return YES, so if you ever find yourself having save performance issues, try setting it to NO.
 

Kenndac

macrumors 6502
Jun 28, 2003
254
62
Also, make sure the text fields aren't marked as "Continuous" in Interface Builder, otherwise they'll cause your behaviour.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.