languages | tags |
---|---|
objc |
delegates, coredata, advanced |
-
Check out what we have for you!
-
You'll find that in order to add a new pirate or a new ship, we our
AddPirateViewController
andAddShipViewController
have to grabFISPiratesDataStore
and call its methods. This makes the controllers highly dependent on eachother... let's reduce this dependency. -
Make
FISPiratesDataStore
register to listen for NSNotifications. -
Make each of your "add" controllers send 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;
```
Your NSNotification addObserver
method should be placed inside of the dispatch_once block of your FISPiratesDataStore
singleton. Don't forget to appropriately remove the observer as well!