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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:10:05+00:00 2026-06-09T09:10:05+00:00

NSString *string=[temp objectAtIndex:row]; [temp removeObjectAtIndex:row]; The object from which string is created no longer

  • 0
   NSString *string=[temp objectAtIndex:row];
   [temp removeObjectAtIndex:row];

The object from which string is created no longer exists; I assume this syntax is straight assignment, thus string should no longer exist, right?

So either I’d use stringWithFormat to create a new string from the object, or send retain to string to be safe, is this correct reasoning?

  • 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-09T09:10:07+00:00Added an answer on June 9, 2026 at 9:10 am

    Assuming you aren’t using ARC or garbage collection, yes, your reasoning about the object’s memory management is correct†. However, you wouldn’t want to use stringWithFormat:. That expects a format string, and it can fail horribly if you pass something that isn’t specifically meant to be one. You could use one of:

    • stringWithString: if you don’t want ownership

    • copy if you just want to make sure you have a safe reference to the string (optionally with autorelease if you don’t plan on keeping the reference around long-term)

    • retain if you definitely want to keep the same object — even if it’s a mutable string — and do want ownership (You probably don’t want this option, as the main difference from copy is that the string could potentially mutate underneath you)

    † By “correct”, I mean you’re right that you shouldn’t assume anything about the object’s lifecycle beyond that point. It might still be alive, but it’s technically not a safe assumption. Thought it worth mentioning because some people aren’t 100% clear on this point.

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

Sidebar

Related Questions

Let's assume I have the string NSString* myString = @Hello,; How can I remove
I have the following code which fetches a string from an array of strings
I am passing a string from objective C to javascript in this way -
I can't get this to work: NSString *string = @!#€%&/()*^*_:;;:;_poawolwasnndaw; NSData *stringData = [string
-- example.h -- @property ( copy ) NSString *string; @property ( retain ) Object
This doesn't seem to work: NSString *string = [[NSString alloc] init]; string = @%@M,
Example: I have this Objective-C code: +(NSString*)stringWithString:(NSString*)string; String: is the name of the argument
can i use like this r not for (NSString *string in userInfo){ lblUserName.text =
I used this method to encode base64 string in object-c, but the app was
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { } In this the value in string I

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.