Hi ! I'm an absolute beginner in XCode and Objective-C, that allmost sounded like the title of the book I'm reading I'm trying to do a small app that read a random line from a text file, when pressing a button on the screen, and then display the result. After a lot of reading in different forums I did find a thread that explained that the best way to it, was to use "plist" instead of a plain textfile... The "jhaList.plist" file is an array, consisting a few lines (strings). Right now it consists of 5 lines:
Line 1
Line 2
Line 3
Line 4
Line 5
But when I get this to work, I want to have about 500 lines in it !
But when running the app, it does display the "generate" button linked to "randomNumber" as expected, when pressing it, the app just quit and just jumps out ! It seems that I don't get any value back to the "randLine" which is connected to an UILabel. Can someone point me in the right direction ? As I said I'm a absolute beginner, so please give basic instructions
//J-E
Last edited by J-E; 02-25-2011 at 07:20 AM.
Reason: No code tags
Thanks jNoxx, for pointing that out ! I'm sorry, but I did not know !
I added [ code] and [ /code] before and after the code. It didn't do any difference, the smileys did show anyway ! So I removed since it didn't work ! Can you give me an example, because it's really anoying to have these smileys in the code ?
when you post there is a # symbol at the top of the text box
Code:
any text that is within the two tags that appear when you hit the # symbol will be up as code not just text
i cant remember jnoxx's words but i think he got a little muddled when posting that, you need to get rid of the spaces between the [ and c or /. I am not entirely certain about the caps - i always do it manually like this:
[ CODE] [ /CODE] but with NO spaces.
Yea, sorry, that's what I said in my post. It says, use the # on top of a post (not the quick post, then press "Go Advanced", and second. I also said, u have to delete the spaces between them, because otherwise i wouldve got me a clean code box, so then u wouldn't understand.
So try fixing it! good luck
Hi ! I'm an absolute beginner in XCode and Objective-C, that allmost sounded like the title of the book I'm reading I'm trying to do a small app that read a random line from a text file, when pressing a button on the screen, and then display the result. After a lot of reading in different forums I did find a thread that explained that the best way to it, was to use "plist" instead of a plain textfile... The "jhaList.plist" file is an array, consisting a few lines (strings). Right now it consists of 5 lines:
Line 1
Line 2
Line 3
Line 4
Line 5
But when I get this to work, I want to have about 500 lines in it !
But when running the app, it does display the "generate" button linked to "randomNumber" as expected, when pressing it, the app just quit and just jumps out ! It seems that I don't get any value back to the "randLine" which is connected to an UILabel. Can someone point me in the right direction ? As I said I'm a absolute beginner, so please give basic instructions
//J-E
You say your plist contains an array, but the code you posted reads the file as a dictionary, then reads an array from that dictionary. How are you creating this plist file?
And you say it just quits and jumps out. You need to run the program in the debugger and step through it line by line, checking the values of all your variables until you find the line that is crashing.
If I had to guess, I would guess that you are not reading your array properly, so it has zero elements. Then when you try to do the "arc4random() % [jhaArray count]" statement, you're crashing on a divide-by-zero error (the modulo operator is a remainder operator, and does a divide to find the answer.)
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.