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

  • Home
  • SEARCH
  • 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 3480776
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:23:05+00:00 2026-05-18T10:23:05+00:00

I’m totally new to Mac OS and iPhone and I’m writing some small app.

  • 0

I’m totally new to Mac OS and iPhone and I’m writing some small app.
I have constant array of image names in resource and I want to switch between these items. I want to display image by the name that is in array (as show below).

However getting the image name string from some index in array seems to cause 3 different errors depending on.. well I don’t know on what. Everytime I start app with new Simulator it causes one of 3 errors.

Online materials just show 1) make array 2) add items 3) use objectAtIndex, but it doesn’t work for me here. Can’t assign string from NSArray to Array.

In header file, inside @interface:

NSMutableArray *imgList;

in code:

imgList = [NSMutableArray arrayWithObjects:@"image01.jpg", @"image02.jpg", @"image03.jpg", nil];
NSString *item;
item = [imgList objectAtIndex:1];
label.text = item

Program randomly has 3 different results for this:

  • once console shows no problem but after few function calls app just closes
  • other time label.text displays “ca.lproj” – no idea why, it’s not part of array
  • other time it’s console error:

2010-11-24 11:43:15.627 Utility[410:207] -[NSCFString objectAtIndex:]: unrecognized selector sent to instance 0x5f44ba0
2010-11-24 11:43:15.630 Utility[410:207] ** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[NSCFString objectAtIndex:]: unrecognized selector sent to instance 0x5f44ba0’
* Call stack at first throw:
(
…
)
terminate called after throwing an instance of ‘NSException’

  • 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-05-18T10:23:05+00:00Added an answer on May 18, 2026 at 10:23 am

    Without seeing a bit more of your code is it a trifle difficult to tell, but it looks as if you have forgotten to retain your array. Once the autoreleasepool ticks, you lose the array, and imgList becomes a dangling pointer; and the memory held by the array becomes overwritten by a string.

    Changing [arrayWithObjects:] to [[alloc] initWithObjects:] should solve your problem; as should adding a retain; but it’s usually clearer what you are doing if you use the proper allocation methods instead.

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

Sidebar

Related Questions

I have an array which has BIG numbers and small numbers in it. I
I have just tried to save a simple *.rtf file with some websites and
I have a small JavaScript validation script that validates inputs based on Regex. I
I am writing an app with both english and french support. The app requests
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am writing an app for my school newspaper, which is run completely online
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am confused How to use looping for Json response Array in another Array.
For some reason, after submitting a string like this Jack’s Spindle from a text

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.