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