Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9022479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:31:14+00:00 2026-06-16T05:31:14+00:00

Hey I’m very new to iPhone programming and I have been searching for hours

  • 0

Hey I’m very new to iPhone programming and I have been searching for hours both on this site and on google for the solution to my problem. Basically I am trying to make an app which selects a random string out of my plist and displays it into a text field. I have tried countless ways, but this way seems to work the best, however it still crashes when I press a button and gives me the error “EXC_ARITHMETIC” on the arc4random line. As well as this error, the NSLog(@”items: &@”, items) displays items: (null) in the log when i press the button. Any help or suggestions are GREATLY appreciated.
P.S. items is an NSMutableArray I already set up in the .h file

-(IBAction)buttonPress {
    NSString* path = [[NSBundle mainBundle] pathForResource:@"ItemList" ofType:@"plist"];
    items = [[NSMutableArray alloc]initWithContentsOfFile:path];
    NSLog(@"items: %@", items);
    NSInteger randomIndex = arc4random() % [items count];
    NSString* randomString = [items objectAtIndex:randomIndex];
    textField.text = randomString;
}

Here’s the plist code

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Array</key>
<array>
    <string>AAA</string>
    <string>BBB</string>
    <string>CCC</string>
    <string>DDD</string>
    <string>EEE</string>
    <string>FFF</string>
    <string>GGG</string>
    <string>HHH</string>
    <string>III</string>
    <string>JJJ</string>
</array>

Thanks guys again for all your help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T05:31:15+00:00Added an answer on June 16, 2026 at 5:31 am

    Your problem is that your plist is not an array, it is a dictionary. So either you need to change your plist,or you need to read it in as a dictionary instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey I have been looking all over the internet and this site for hours
Hey all- I have looked this up on here and Google but none of
Hey i have been looking around and i cant find a way to get
*Hey , I have finished developing my app In my iphone apps I have
hey guys having this really simple problem but cant seem to figure out have
Hey all i have a JSFiddle that i have been working on with trying
Hey I have following code like this public object RetrieveItemRun(int item) { if (dictionary.ContainsKey(item))
Hey all. I've been been trying to figure this out for a while now.
Hey guys! I have this little problem: I have one ViewController which adds 2
Hey I have been following gcm tutorial to create gcm-demo-server and a demo-client. All

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.