'NSMutableArray' 没有可见的 @ 接口声明了选择器 'shuffledArray'
No visible @ interface for 'NSMutableArray' declares the selector 'shuffledArray'
这应该很简单。我只想随机化一个 NSArray。我发现这个简洁的小插件可以完成名为 "shuffledArray" 的工作。 https://github.com/bryanluby/NSArray-Shuffle
所以我现在应该完成了。我导入了 NSArray+Shuffle.h
#import "NSArray+Shuffle.h"
我添加了一个 shuffledArray 接口:
@interface TipCollectionViewController ()
{
AJNotificationView *panel;
NSString * query;
// CLLocationManager * locationManager;
NSMutableArray * _entries;
// NSArray *shuffledArray;
int page;
int c_page;
NSArray *mostPopular;
NSArray *ranDom;
NSRange blueRange;
//int pageNum;
//NSString *phpLink;
NSMutableData *responsePlaceData;
}
-(NSMutableArray *)shuffledArray;
@property (nonatomic, weak) IBOutlet CollectionLayout *tipsLayout;
@property (nonatomic, strong) UIImageView *menuImage;
//@property SESpringBoard *board2;
@property (nonatomic, retain) NSMutableArray *itemCounts;
@end
...但是当我尝试随机化数组时:
ranDom = [_entries shuffledArray];
它告诉我不存在名为 shuffledArray 的 NSMutableArray 接口。
知道我哪里出错了吗?这让我很头疼。
我会尽我所能...
首先这个家伙的代码、说明和 github 页面都是错误的。
ranDom = [_entries shuffledArray];
...永远不会工作。
因为在源码中他的方法其实是:
bjl_shuffledArray
所以...
ranDom = [_entries bjl_shuffledArray];
有效。
第二个问题其实是我的错
我正在写信给:
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
...当我应该写信给:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
所以解决方案是:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
{
ranDom = [_entries bjl_shuffledArray];
mostPopular = [[_entries reverseObjectEnumerator]allObjects];
if (isChangeData){
NSLog(@"Most Popular");
dataLand = mostPopular;
}
else if(isChangeData2){
NSLog(@"Random");
dataLand = ranDom;
}
else{
NSLog(@"All");
dataLand = _entries;
}
Place *p = [dataLand objectAtIndex:indexPath.item];
}
"dataLand" 是我想出的另一个 NSArray。
现在可以了!我真的需要开始多睡一会儿。
这应该很简单。我只想随机化一个 NSArray。我发现这个简洁的小插件可以完成名为 "shuffledArray" 的工作。 https://github.com/bryanluby/NSArray-Shuffle
所以我现在应该完成了。我导入了 NSArray+Shuffle.h
#import "NSArray+Shuffle.h"
我添加了一个 shuffledArray 接口:
@interface TipCollectionViewController ()
{
AJNotificationView *panel;
NSString * query;
// CLLocationManager * locationManager;
NSMutableArray * _entries;
// NSArray *shuffledArray;
int page;
int c_page;
NSArray *mostPopular;
NSArray *ranDom;
NSRange blueRange;
//int pageNum;
//NSString *phpLink;
NSMutableData *responsePlaceData;
}
-(NSMutableArray *)shuffledArray;
@property (nonatomic, weak) IBOutlet CollectionLayout *tipsLayout;
@property (nonatomic, strong) UIImageView *menuImage;
//@property SESpringBoard *board2;
@property (nonatomic, retain) NSMutableArray *itemCounts;
@end
...但是当我尝试随机化数组时:
ranDom = [_entries shuffledArray];
它告诉我不存在名为 shuffledArray 的 NSMutableArray 接口。
知道我哪里出错了吗?这让我很头疼。
我会尽我所能...
首先这个家伙的代码、说明和 github 页面都是错误的。
ranDom = [_entries shuffledArray];
...永远不会工作。
因为在源码中他的方法其实是:
bjl_shuffledArray
所以...
ranDom = [_entries bjl_shuffledArray];
有效。
第二个问题其实是我的错
我正在写信给:
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
...当我应该写信给:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
所以解决方案是:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
{
ranDom = [_entries bjl_shuffledArray];
mostPopular = [[_entries reverseObjectEnumerator]allObjects];
if (isChangeData){
NSLog(@"Most Popular");
dataLand = mostPopular;
}
else if(isChangeData2){
NSLog(@"Random");
dataLand = ranDom;
}
else{
NSLog(@"All");
dataLand = _entries;
}
Place *p = [dataLand objectAtIndex:indexPath.item];
}
"dataLand" 是我想出的另一个 NSArray。
现在可以了!我真的需要开始多睡一会儿。