NSArray can't shuffle
I am trying to use the new shuffle method to shuffle my array: https://developer.apple.com/documentation/foundation/nsarray/1640855-shuffledarray?language=objc. But I just get an error saying: No visible @interface for 'NSArray' declares the selector 'shuffledArray'
.
This is my code:
NSArray *shuffledArray = [array shuffledArray];
And my project is iOS 10.0+
As you can see on the right column of the documentation, although this is a method on NSArray
, it's located in the GameplayKit
framework.
You need to import the framework :
#import <GameplayKit/GameplayKit.h>
You should always use @import
for this, as it offers some advantages over #import of frameworks. So on this case it would be: @import GameplayKit;
上一篇: NSDictionary,NSArray,NSSet和效率
下一篇: NSArray无法洗牌