Captain Morgan's Notifications -- Advanced Lab
Instructions
-
Check out what we have for you!
-
You'll find that in order to add a new pirate or a new ship, our
AddPirateViewController
andAddShipViewController
have to grabFISPiratesDataStore
and call its methods. This makes the controllers highly dependent on each other... let's reduce this dependency. -
Make
FISPiratesDataStore
register to listen for NSNotifications. -
Make each of your "add" controllers broadcast an NSNotification with the information that they take from the user attached as an
NSDictionary
. -
Create categories on your
Ship
andPirate
classes, each with a convenience class method as shown below:
+(instancetype)shipFromDictionary:(NSDictionary *)dictionary
andContext:(NSManagedObjectContext *)context;
+(instancetype)pirateFromDictionary:(NSDictionary *)dictionary
andContext:(NSManagedObjectContext *)context;
```
Hint
Your NSNotificationCenter addObserver
method should be placed inside of the init method of your FISPiratesDataStore
. Don't forget to appropriately remove the observer as well!
View Captain Morgan's Notifications -- Advanced Lab on Learn.co and start learning to code for free.