Title: UITableView performance and CoreData
Tags: performance;uitableview;core-data
Question: I've been profiling my table view and one line in particular is dropping my frame rate from 50 to about 30... the thing is, the line of code seems pretty harmless.
It is in:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
I've removed all none relevant code and just left the line as:
oneSession.totalForThisMetric = [NSNumber numberWithInt:1];
What is core data doing with it's setter than hurts performance so bad? totalForThisMetric, not only is monatomic, retain - but it's also a transient core data property!

Here is the accepted answer: The thing is: transient properties are not meant to be set this way. You should set them in the -awakeFromFetch and/or -awakeFromInsert methods, depending on your needs. Please read the relevant documentation on "Object life cycle initialization and deallocation" and modify your code accordingly.
Comment for this answer: What if the transient property is changing through the life of the managed object - using awakeFromFetch to update it would require the object to be re-faulted each time the property is changed?
Comment for this answer: @deanWonbourne: re-faulting can not be avoided in that case I guess: you can not transform the dynamic nature of a transient property into a static nature.
Comment for this answer: @bandejaoaisa: the answer explains the performance hit: you are doing something you should not do in a method that must be as fast as possible in building a tableview cell. You should refrain from doing anything else which is not strictly related to setting up a cell.
Comment for this answer: ah ha. Thanks for pointing this out. I'll read up on this. I'm new to CoreData - so I'm picking up bits as I work through my first project. Thanks  .... although it doesn't answer why it's hitting the performance so bad.
Comment for this answer: @unforgiven. Yeah, you're right. Someone else told me the same thing.
Comment for this answer: In awakeFromFetch i'm trying to get set some data into a transient property. But this method is in my model object - doesn't this break my MVC separation? The data I need is in my Controller object and is a sum total. To be more specific, each model object has a value in it, and I also want them to have a percentage of total transient value. This total has to be calculated - and I was going to set this in each model object so that each model knows its own percent.


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2011:00:08/30/11', 'FavoriteCount': 1.0, 'PostTypeId': 1, 'Tags': '<performance><uitableview><core-data>', 'Title': 'UITableView performance and CoreData', 'ViewCount': 185, 'id': 7249828, 'user_AboutMe': '<p>Freelance iOS Developer in London, UK.</p>\n\n<p>[LinkedIn Profile][1]</p>\n\n<p>Owner of [DevedUp Ltd][2]</p>\n', 'user_AccountId': 114059.0, 'user_DisplayName': 'bandejapaisa', 'user_Reputation': 26015.0, 'user_Views': 1306.0, 'user_id': 300098.0}}