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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:40:47+00:00 2026-06-14T16:40:47+00:00

Actually I am working on a project with ARC enabled. I know using alloc

  • 0

Actually I am working on a project with ARC enabled. I know using alloc and init is taking ownership of the object. I know, If I create a string like this

NSString *myString = [[NSString alloc]initWithFormat:@"Something"];

then I need to release the myString on myself. What If I am using ARC enabled? I cannot release on myself. So will it create a leak? Or should I don’t create object like this?

I can create a string like below code too.

NSString *myString = [NSString stringWithFormat:@"Something"];

But which type I need to use exactly for ARC enabled project ? What will happen if I use first type?

  • 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-14T16:40:49+00:00Added an answer on June 14, 2026 at 4:40 pm

    If you use ARC, all the necessary release calls will be added for you when you compile. It will not leak.

    The difference between

    NSString *myString = [[NSString alloc]initWithFormat:@"Something"];
    

    and

    NSString *myString = [NSString stringWithFormat:@"Something"];
    

    is that the first one will automatically released after the last reference to myString in that block, while the second one is an autoreleased instance that will only be released at the end of the run loop. It’s not a big difference, but if you’re using a lot of objects, try to avoid autoreleased ones to keep memory usage low.

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

Sidebar

Related Questions

I'm actually working on a Symfony project at work and we are using Lucene
I'm working on a WTL project, actually WTL 8.1 with VS2008. In many tutorials
I'm actually working on a job for school and I try to create a
Im actually working in a django project and I'm not sure about the best
I am working on a project involving struts2 and hibernate.Actually I want to execute
I actually working on a website-project. Behind my website, I´ve got a database with
Actually I'm working on simple project MVC4 + EF in which I have relation
I am working on this project: http://www.e-pedkelnes.beta.verskis.lt/ Actually what I have to do is
I'm working on a project creating a fairly simple one-to-many host-to-slave network using a
I am working on a project with several modules. The development tree looks like:

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.