Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread Display Modes
Old Jan 27, 2011, 09:10 AM   #1
macrumors 6502
Join Date: Mar 2010
Location: Maine, USA, Earth, Solar System, Milky Way, Universe
Random Numbers?

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"]];
If that worked, it would be perfect
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.
lynkynpark86 is offline   0 Reply With Quote
Old Jan 28, 2011, 06:11 AM   #2
macrumors 6502
Join Date: Oct 2008
Location: La la land
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
Nobita is offline   0 Reply With Quote

MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Random Number Seeding GothicChess.Com Mac Programming 10 Jun 18, 2007 12:02 PM
Generating normally distributed random numbers in C++ vgoklani Mac Programming 2 Mar 9, 2007 11:23 AM
Random numbers for c++ Serac Mac Programming 8 Jan 30, 2006 12:31 AM
random number generator in Excel for Mac mmoin General Mac Discussion 1 Feb 11, 2003 08:57 PM

All times are GMT -5. The time now is 05:20 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013,, LLC