Please note, this blog entry is from a previous course. You might want to check out the current one.
Use lazy instantiation to allocate and initialize this property (in the property’s getter)
so that it starts off with a full deck of PlayingCards.
Use the getter to check if there is a valid deck. If not, initialize one …
#import "PlayingCardDeck.h" ... - (Deck *)deck { if (!_deck) { _deck = [[PlayingCardDeck alloc] init]; } return _deck; }
The complete code is available on github.
![Share on Facebook Facebook](https://cs193p.m2m.at/wp-content/plugins/social-media-feather/synved-social/image/social/regular/16x16/facebook.png)
![Share on Twitter twitter](https://cs193p.m2m.at/wp-content/plugins/social-media-feather/synved-social/image/social/regular/16x16/twitter.png)
![Share on Reddit reddit](https://cs193p.m2m.at/wp-content/plugins/social-media-feather/synved-social/image/social/regular/16x16/reddit.png)
![Pin it with Pinterest pinterest](https://cs193p.m2m.at/wp-content/plugins/social-media-feather/synved-social/image/social/regular/16x16/pinterest.png)
![Share on Linkedin linkedin](https://cs193p.m2m.at/wp-content/plugins/social-media-feather/synved-social/image/social/regular/16x16/linkedin.png)
![Share on tumblr tumblr](https://cs193p.m2m.at/wp-content/plugins/social-media-feather/synved-social/image/social/regular/16x16/tumblr.png)
![Share by email mail](https://cs193p.m2m.at/wp-content/plugins/social-media-feather/synved-social/image/social/regular/16x16/mail.png)
![Share on Facebook Facebook](https://cs193p.m2m.at/wp-content/plugins/social-media-feather/synved-social/image/social/regular/32x32/facebook.png)
![Share on Twitter twitter](https://cs193p.m2m.at/wp-content/plugins/social-media-feather/synved-social/image/social/regular/32x32/twitter.png)
![Share on Reddit reddit](https://cs193p.m2m.at/wp-content/plugins/social-media-feather/synved-social/image/social/regular/32x32/reddit.png)
![Pin it with Pinterest pinterest](https://cs193p.m2m.at/wp-content/plugins/social-media-feather/synved-social/image/social/regular/32x32/pinterest.png)
![Share on Linkedin linkedin](https://cs193p.m2m.at/wp-content/plugins/social-media-feather/synved-social/image/social/regular/32x32/linkedin.png)
![Share on tumblr tumblr](https://cs193p.m2m.at/wp-content/plugins/social-media-feather/synved-social/image/social/regular/32x32/tumblr.png)
![Share by email mail](https://cs193p.m2m.at/wp-content/plugins/social-media-feather/synved-social/image/social/regular/32x32/mail.png)