我目前使用一个系统,如果用户升级了应用程序,所有结果都在颜色图表中查看。
在 ViewController.m 的顶部
int kMaxRecords = 300;
就在数组之前;
allText = [[NSMutableArray alloc] init];
然后是 300 种颜色,例如;
[allText addObject:@"Indigo"];
等等 ...
这由 IBAction 控制;
- (IBAction)setRandomText {
selectedRecNumber = (arc4random() % kMaxRecords);
NSString *text = [allText objectAtIndex:selectedRecNumber];
[randomText setText:text];
if ([MKStoreManager featureAPurchased]) {
kMaxRecords = [allText count];
}else{
// this is where I would like to control a set limit of colors, let's say, 50, or 100
}
}
count++;
}
那么在 }else{ 之后,我将如何设置,例如,只显示 300 种颜色中的前 100 种颜色?我尝试使用;
kMaxRecords = 100;
然而它没有工作......
编辑 -
为了进一步复杂化,让我们引入更多可能性;
if ([MKStoreManager featureAPurchased] || [MKStoreManager featureDPurchased] ||[MKStoreManager featureEPurchased] ) {
kMaxRecords = [allText count];
}else{
if (![MKStoreManager featureAPurchased] || ![MKStoreManager featureCPurchased] || ![MKStoreManager featureDPurchased] || ![MKStoreManager featureEPurchased] ) {
kMaxRecords = 35;
allText = [[allText subarrayWithRange:NSMakeRange(0, 34)] mutableCopy];
}else{
if ([MKStoreManager featureCPurchased] ) {
kMaxRecords = 135;
allText = [[allText subarrayWithRange:NSMakeRange(0, 134)] mutableCopy];
}
}
}
}
编辑 2 - 这是 viewDidLoad;
- (void)viewDidLoad {
allText = [[NSMutableArray alloc] init];
[allText addObject:@"Green"];
[allText addObject:@"Orange"];
and more and more...
if ([MKStoreManager featureAPurchased] || [MKStoreManager featureDPurchased] ||[MKStoreManager featureEPurchased] ) {
kMaxRecords = [allText count];
}else{
if (![MKStoreManager featureAPurchased] || ![MKStoreManager featureCPurchased] || ![MKStoreManager featureDPurchased] || ![MKStoreManager featureEPurchased] ) {
kMaxRecords = 35;
allText = [[allText subarrayWithRange:NSMakeRange(0, 34)] mutableCopy];
}else{
if ([MKStoreManager featureCPurchased] ) {
kMaxRecords = 135;
allText = [[allText subarrayWithRange:NSMakeRange(0, 134)] mutableCopy];
}
}
}
}
- (IBAction)setRandomText {
selectedRecNumber = (arc4random() % kMaxRecords);
NSString *text = [allText objectAtIndex:selectedRecNumber];
[randomText setText:text];
count++;
}