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 865103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:35:18+00:00 2026-05-15T09:35:18+00:00

It seems that Objective C jumps thru hoops to make seemingly simple tasks extremely

  • 0

It seems that Objective C jumps thru hoops to make seemingly simple tasks extremely difficult.

I simply need to create a sequence of strings, image1.jpg, image2.jpg, etc etc

ie in a loop
var imgString:String='image'+i+'.jpg;

I assume a best practice is to use a NSMutableString with appendString method?

What am I doing wrong??

NSMutableString *imgString;

    for(int i=1;i<=NUMIMAGES;i++){
    imgString.appendString(@"image"+i+@".jpg");
}

I get the following error

error: request for member ‘appendString’ in something not a structure
or union

  • 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-15T09:35:19+00:00Added an answer on May 15, 2026 at 9:35 am

    I cannot possibly imagine how yielding the string image5image4image3image2image1.jpg in string3 in your “answer” to your own question could be construed as useful or a solution (I pasted your code into an Xcode Foundation tool project w/NUMIMAGES set to 5).

    It seems that Objective C jumps thru hoops to make seemingly simple tasks extremely difficult.

    Read the Objective-C Guide and the String Programming Guide, then make draw your conclusions. Criticizing something you don’t understand is generally counter-productive (we’ve all done it, though — easy to do when frustrated).

    I simply need to create a sequence of strings, image1.jpg, image2.jpg, etc etc

    Naive solution:

    #define NUMIMAGES 5
    NSMutableArray *fileNames = [NSMutableArray array];
    for(int i = 0; i<5; i++)
        [fileNames addObject: [NSString stringWithFormat: @"image%d.jpg", i]];
    NSLog(@"fileNames %@", fileNames);
    

    Outputs:

    fileNames (
        "image0.jpg",
        "image1.jpg",
        "image2.jpg",
        "image3.jpg",
        "image4.jpg"
    )
    

    Note that there isn’t anything particularly wrong with the naive solution. It is just more fragile, less efficient, and more code than is necessary.

    One Possible Better Solution

    1. Add all images into your application project as resources.

    2. Use the NSBundle API to grab URLs to all images at once.

    I.e.:

    NSArray *paths = [[NSBundle mainBundle] pathsForResourcesOfType: @"jpg" inDirectory: nil];
    

    Not only does this remove hardcoding of image names from your code, it also allows the system to optimize directory enumeration and path generation. If you want to load only a subset of images — say you are writing a game and have a series of images related to monsters — then put all the related images in a single directory, add the directory to your Resources, then pass that directory’s name as the second argument to the above method.

    All of this — and much more — is documented in the resource programming guide.

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

Sidebar

Ask A Question

Stats

  • Questions 432k
  • Answers 432k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Found the solution: <module name="Regexp"> <property name="format" value="(interface [a-zA-Z0-9 &lt;&gt;,\.]*… May 15, 2026 at 2:33 pm
  • Editorial Team
    Editorial Team added an answer The documentation explains how to write Custom Validators. May 15, 2026 at 2:33 pm
  • Editorial Team
    Editorial Team added an answer The first control you are talking about is the SlidingDrawer,… May 15, 2026 at 2:32 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.