I am new to Objective-C and learning by trial and error! Please forgive me if this question is somewhat naïve.
I've created an array of images and need to shuffle them. I've used the advice given here:
What's the Best Way to Shuffle an NSMutableArray?
And now I need to implement the method 'shuffle'. I have separate category for my array and its implementation:
@interface theKid : NSObject {
NSMutableArray* _cards;
}
@property(strong, nonatomic, readonly) NSMutableArray *cards;
- (UIImage*) shuffledCard;
@end
But now I can't figure out how to implement 'shuffle':
@implementation theKid
- (NSMutableArray *) cards {
_cards = [[NSMutableArray alloc] initWithObjects:
[UIImage imageNamed:@"One"],
[UIImage imageNamed:@"Two"],
[UIImage imageNamed:@"Three"],
[UIImage imageNamed:@"Four"], nil];
return _cards;
}
- (UIImage*) shuffledCard {
shuffle *cards;
return [cards objectAtIndex:0];
}
@end
This just effects a blank screen when I try to call 'shuffledCard'. Any advice much appreciated.