Great tutorial; clear, concise and well thought out. Thank you ! Look forward to the next installment.
Nice tutorial. Looking forward to the next one.
Awesome stuff! Thanks a lot!
You don’t need to import Cards.h in Deck.h.
Deck.h just needs to be aware that the Card class exists so you can use a forward reference instead. @class Card;
@class Card;
@interface Deck : NSObject {
@private NSMutableArray *cards; }
- (void) shuffle; - (Card *) draw; - (NSInteger) cardsRemaining;
@end
Forgot to mention that you’ll need to make sure you do the #import Card.h in Deck.m
Why do you feel that your approach is preferred?
With mine, there is only one import statement rather than declaring the @class in the .h and doing the import in the .m.
I have seen that style before and I’m curious as to its benefits, perhaps you can shed some light on it for me?
Because your way is prone to circular import problems. By doing forward declares, you never have to worry about such things.
@Brian,
Ahh, totally. Can’t believe I didn’t see that.
I will make sure to do forward declares in future tutorials.
Thanks for pointing that out.
Nice tutorial. Looking forward the next part.
I really appreciate you taking the time to step us noobs through this. It’s like gold to someone trying to wrap their brain around obj.c.
Great Tutorial.
Waiting for next part
thanks for article…
good luck !
Doing a build and analyze complains about randomSort() it wants the return type to be an NSInteger.
I changed it to this and the warning went away
NSInteger randomSort(id obj1, id obj2, void *context ) {
Good catch, it’s pretty trivial though. Should work either way. Clang is a little picky sometimes.
You have some HTML codes in your code. Instead of “less than” and “greater than” signs HTML codes < and &rt show up.
yeah, stupid wordpress plugin. I’d be open for suggestions for better ones?
Nice ! thanks keep these coming.
Why do you break all C and Objective-C conventions in so many places? You don’t even use UPPER case for defines????
#define Ace 1 #define Jack 11 #define Queen 12 #define King 13
Meh…
*PLEASE* post only code that you know will compile correctly:
for(int x = 0; x &-l-t-; 500; x++) {
Kimmy,
This is an issue with the plugin for wordpress. I don’t have control over it. Download the sample which does compile.
Sorry for your inconvenience.
fantastic. I have been a fan and follower for the last few months and have found your tutes a great tool for learning. Thanks for taking the time to reach out to us. look forward to more.
Eagerly awaiting part two. Don’t pay attention to the semantic nazis, this was/is a great tutorial.
Hi, nice tuto, i’m creating a card game (bellote) and i used your code and it helped a lot,
actually i’ve a problem with the split functiun (share the deck in 4 hands), if you have idea or a few time to help, i’ll love it!
@+ and thx
Great tutorial can’t wait for part two.
Brandon,
Awesome job, this was a great tutorial. It had been awhile since I had been on icodeblog, love the new design!
Great Tutorial so far, but when is the next part coming?
This is like a good series. Cliffhanger and then waiting for the next episode. But this one seems to never come.
When is part 2? This is great.
[...] Original post on iCodeBlog [...]
Your email is never published nor shared. Required fields are marked *
You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">
28 Comments
Great tutorial; clear, concise and well thought out. Thank you ! Look forward to the next installment.
Nice tutorial. Looking forward to the next one.
Awesome stuff! Thanks a lot!
You don’t need to import Cards.h in Deck.h.
Deck.h just needs to be aware that the Card class exists so you can use a forward reference instead.
@class Card;
@interface Deck : NSObject {@privateNSMutableArray *cards;
}
- (void) shuffle;- (Card *) draw;
- (NSInteger) cardsRemaining;
@end
Forgot to mention that you’ll need to make sure you do the #import Card.h in Deck.m
Why do you feel that your approach is preferred?
With mine, there is only one import statement rather than declaring the @class in the .h and doing the import in the .m.
I have seen that style before and I’m curious as to its benefits, perhaps you can shed some light on it for me?
Because your way is prone to circular import problems.
By doing forward declares, you never have to worry about such things.
@Brian,
Ahh, totally. Can’t believe I didn’t see that.
I will make sure to do forward declares in future tutorials.
Thanks for pointing that out.
Nice tutorial.
Looking forward the next part.
I really appreciate you taking the time to step us noobs through this. It’s like gold to someone trying to wrap their brain around obj.c.
Great Tutorial.
Waiting for next part
thanks for article…
good luck !
Doing a build and analyze complains about randomSort() it wants the return type to be an NSInteger.
I changed it to this and the warning went away
NSInteger randomSort(id obj1, id obj2, void *context ) {
Good catch, it’s pretty trivial though. Should work either way. Clang is a little picky sometimes.
You have some HTML codes in your code. Instead of “less than” and “greater than” signs HTML codes < and &rt show up.
yeah, stupid wordpress plugin. I’d be open for suggestions for better ones?
Nice ! thanks keep these coming.
Why do you break all C and Objective-C conventions in so many places? You don’t even use UPPER case for defines????
#define Ace 1
#define Jack 11
#define Queen 12
#define King 13
Meh…
*PLEASE* post only code that you know will compile correctly:
for(int x = 0; x &-l-t-; 500; x++) {
Kimmy,
This is an issue with the plugin for wordpress. I don’t have control over it. Download the sample which does compile.
Sorry for your inconvenience.
fantastic. I have been a fan and follower for the last few months and have found your tutes a great tool for learning. Thanks for taking the time to reach out to us. look forward to more.
Eagerly awaiting part two. Don’t pay attention to the semantic nazis, this was/is a great tutorial.
Hi,
nice tuto, i’m creating a card game (bellote) and i used your code and it helped a lot,
actually i’ve a problem with the split functiun (share the deck in 4 hands), if you have idea or a few time to help, i’ll love it!
@+ and thx
Great tutorial can’t wait for part two.
Brandon,
Awesome job, this was a great tutorial. It had been awhile since I had been on icodeblog, love the new design!
Great Tutorial so far,
but when is the next part coming?
This is like a good series. Cliffhanger and then waiting for the next episode.
But this one seems to never come.
When is part 2? This is great.
One Trackback
[...] Original post on iCodeBlog [...]