|Jan 27, 2011, 10:10 AM||#1|
I am making an iPhone app to randomly pick a 6-digit ticket number from about 500 numbers. The app will be run in the simulator. It is for a technology-related contest, and the fact that I am using an iPhone app is entirely for show. I wanted to use an NSArray, but I think loading the data from a file will be much easier than that, since the tickets are going to be scanned, so I will already have all the numbers in a .txt file. How can I load 500 numbers from a txt file, with each of the 500 numbers on a line, totaling 500 lines? Is there some way to do something like:
NSArray *tickets = [NSArray arrayWithObjects:[pathToResource:"tickets" of type:"txt"]];
White MacBook, 2.13 GHz, 2 GB RAM, 160 GB HD
Dell w/ 4GB RAM, AMD Athlon
iPod Touch 4G (or 5G :P), 32GB, iOS 5.1, awaiting jailbreak.
|Jan 28, 2011, 07:11 AM||#2|
You can't just do that. Google around. You basically have to do this in a kind of three steps:
1. Locate the file, get the path
2. Load the file
3. Convert them to NSArray.
BTW out of curiosity how did you format the file? Just numbers separated by line breaks? If it was more structured like XML or something like that it might be easier. Maybe.
My mind is beautiful
|Thread Tools||Search this Thread|
|thread||Thread Starter||Forum||Replies||Last Post|
|Random Number Seeding||GothicChess.Com||Mac Programming||10||Jun 18, 2007 01:02 PM|
|Generating normally distributed random numbers in C++||vgoklani||Mac Programming||2||Mar 9, 2007 12:23 PM|
|Random numbers for c++||Serac||Mac Programming||8||Jan 30, 2006 01:31 AM|
|random number generator in Excel for Mac||mmoin||General Mac Discussion||1||Feb 11, 2003 09:57 PM|
All times are GMT -5. The time now is 07:47 AM.