|Jan 27, 2011, 09: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, 06: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|
|My keychain access shows random numbers and letters for my passwords, please help :)||xcstryder||OS X Mavericks (10.9)||1||Apr 15, 2014 12:33 AM|
|Numbers vs Excel when mixing text & numbers||TheBlackLabEdge||Mac Applications and Mac App Store||5||Mar 6, 2014 08:29 PM|
|Advanced Search starts with lots of "random" numbers as keywords||simsaladimbamba||Site and Forum Feedback||6||Feb 18, 2014 10:32 PM|
|How to generate quality random numbers in bulk?||Qaanol||Mac Programming||7||Jul 21, 2013 01:46 PM|
|MBP 2010 random/not so random crashes?||Kobaine||MacBook Pro||0||Jan 3, 2013 04:10 PM|
All times are GMT -5. The time now is 02:36 AM.