In App Purchase Question
So I have an IBAction:
- (IBAction)yesNo {
int rNumber = rand() % 26;
switch (rNumber) {
case 0:
result.text = @"Never";
break;
case 1:
result.text = @"If you're lucky...";
break;
case 3:
result.text = @"Think twice";
break;
case 4:
result.text = @"GO!";
break;
case 5:
result.text = @"Hmmm. Try me again";
break;
case 6:
result.text = @"As I see it, yes";
break;
case 7:
result.text = @"It is certain";
break;
case 8:
result.text = @"It is decidedly so";
break;
case 9:
result.text = @"Most likely";
break;
case 10:
result.text = @"Outlook good";
break;
case 11:
result.text = @"Signs point to yes";
break;
case 12:
result.text = @"Without a doubt";
break;
case 13:
result.text = @"Yes";
break;
case 14:
result.text = @"Yes - definitely";
break;
case 15:
result.text = @"You may rely on it";
break;
case 16:
result.text = @"Reply hazy, try again";
break;
case 17:
result.text = @"Ask again later";
break;
case 18:
result.text = @"Better not tell you now";
break;
case 19:
result.text = @"Cannot predict now";
break;
case 20:
result.text = @"Shake again";
break;
case 21:
result.text = @"Don't count on it";
break;
case 22:
result.text = @"My reply is no";
break;
case 23:
result.text = @"My sources say no";
break;
case 24:
result.text = @"Outlook not so good";
break;
case 25:
result.text = @"Very doubtful";
break;
default:
break;
}
}
On an in app purchase, I want to replace the result开发者_开发问答.text
values. I do not want to have to use core data, as the entire app has been written without it. Do I have to use core data?
On an in app purchase, I want to replace the result.text values. I do not want to have to use core data, as the entire app has been written without it. Do I have to use core data?
Why do you think you would need Core Data?
Reading between the lines, it seems like you just need a text file with one result per line. Read the file and break it up:
NSString *resultsData = [NSString stringWithContentsOfFile:...];
NSArray *results = [resultsData componentsSeparatedByString:@"\n"];
[...someController... useTheseResultsMan: results];
Then, your yesNo
method would just grab the results from the array:
results.text = [[...someController... resultsToBeUsedMan] objectAtIndex: rNumber];
You could much more easily use an NSArray read from a plist. Create 2 new plists with all of your phrases, one with the purchased data and one with the other.
if (userHasPaid) {
NSArray *myArray = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"myPurchasedArray" ofType:@"plist"];
} else {
NSArray *myArray = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"myFreeArray" ofType:@"plist"];
}
Then:
- (IBAction)yesNo {
result.text = [myArray objectAtIndex:rNumber];
}
CoreData is really intended for very large data sets. Your scenario is much, much more simple.
精彩评论