Day 15 at Mobile Makers (Core Data, Relationships(code related))

Today I learned a lot but some things that really stuck are that viewDidLoad only gets called once. So if you go to another view controller and come back to the original one, then viewDidLoad will not be called. So then if you need to reload data or anything else back in the original view controller, you need to put those methods in the viewWillAppear. ViewWillAppear gets called each time the view “appears.”

self.items = [[self.managedObjectContext executeFetchRequest:request error:nil] mutableCopy];

The code above is really cool because it makes a mutableCopy of the array returned and sets it as self.items. This allows us to go from a NSArray to a NSMutableArray because originally, fetch request returns an array.

Don showed us this super awesome thing…

cell.detailTextLabel.text = @(adventurer.raid.count).description;

In the code above, the super awesome thing is in the (). Basically this expression that starts with @(code here). This expression allows us to turn anything into an object and call a description method on it. So you can turn a integer into a NSNumber or whatever else you like.

Today was really challenging for everyone, from simple mistakes with naming to anything else you can think of, we all struggled. I barely made it to the second step out of six from the MVP and that was right in line with half the class and the other half didn’t even make it that far.

I’m trying to picture how core data ties into using backend databases like Parse. I am thinking that we can save images we get sent on our own device so that we can still view them offline and then we get new images and items from the Parse backend or whatever else when we are online by using things such as pull to refresh etc…

“It’s not about what you know, it’s about what you know you can do”

-Blake

Leave a comment