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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T12:07:09+00:00 2026-05-12T12:07:09+00:00

I have a little foundation tool test (Objective-C) that I am playing with and

  • 0

I have a little foundation tool test (Objective-C) that I am playing with and I have a few questions …

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

    int planetLoop;
    NSString *tempString;
    NSMutableArray *planetArray = [[NSMutableArray alloc] init];

    NSLog(@"STRING ARRAY ... Start");
    for(planetLoop=0; planetLoop<10; planetLoop++) {
        tempString = [NSString stringWithFormat: @"Planet_%03d", planetLoop+1];
        NSLog(@"Planet_%03d", planetLoop+1);
        [planetArray addObject:tempString];
    }

    [planetArray release];
    [pool drain];
    return 0;
}

First, usually I release an object after adding it to an array, but am I right in thinking that what I have currently is right because “tempString” is a string literal, and as such does not need to be allocated or released?

Secondly, when I run this (prior to execution) I get the following eror “unable to read unknown load command 0x80000022” if this a problem with my code? from searching on google it looks like it might be a bug in xCode 3.1.2, anyone have any ideas?

Finally anything I am doing wrong, the idea is to fill an array with 10 string “Planet_001” through to “Planet_010”

EDIT: Ah, I see, thats because of the “= [NSString” bit i.e.

// Autoreleased object
tempString = [NSString stringWithFormat: @"Planet_%03d", planetLoop+1];
// String literal
tempString = @"Planet_"; 

many thanks, much appreciated -gary-

  • 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-12T12:07:10+00:00Added an answer on May 12, 2026 at 12:07 pm

    tempString isn’t actually a string literal. @"Planet_%03d" is a string literal. tempString is an autoreleased object, meaning that it will be released when the NSAutoreleasePool is drained. Basically, the memory is already managed and you don’t have to do anything.

    The rule is: If you new, alloc, copy or retain an object, then you have to release it. Otherwise, the memory is already managed, probably by an autorelease.

    Also, you forgot to release pool. Other than that, it looks fine.

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

Sidebar

Related Questions

Ok. I have this little bit of code that is supposed to use text
I have little working knowledge of python. I know that there is something called
I am a little ashamed to say that I have never used an ORM;
I am reviewing this technology but have a few design concerns that made me
I have little bit longer question for you - but hope answer will be
I have little question about how web browser retrieve webpage? I know this User
I have little doubt about string reading in C. string reading functions like gets,
I have little snippet for validatin' my form. I need help to position the
i have little dilemma, i often use data-bound controls such as Gridview in conjunction
I have little problem with a replacement of a little part in an url.

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.