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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:12:56+00:00 2026-06-17T00:12:56+00:00

I’m currently trying to learn Objective-C by reading books and online tutorials, also referring

  • 0

I’m currently trying to learn Objective-C by reading books and online tutorials, also referring to the Apple documentation but some things just don’t click. I have a question about classes, I have been using the NSString for a while now without putting too much attention on how it is used.

I was under the impression that in order for someone to be able to use a method from a certain class in Objective-C you first needed to instantiate it, something like…

ClasssName *varName = [[ClassName alloc]init];

Then you would call methods like…

[varName someMethod];

But looking at how the NSString is used I’m now I little confused, for instance here is how we would normally use it…

NSString *someString = @"some text here";
[someString stringByAppendingFormat:  @"some text = %d", 3];

Following what I have read about classes we would need to do something like the following instead.

NSString *someString  =  [[NSString alloc]initWithString: @"some text here"];
[someString stringByAppendingFormat:  @"some text = %d", 3];

Can someone explain why some classes do not require instantiation before using its methods?

  • 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-17T00:12:58+00:00Added an answer on June 17, 2026 at 12:12 am

    Objective-C knows some abbreviations that are called literals. The compiler is aware of the special notation. A string literal is compiled into the binary and exits throughout the lifetime of an app.

    For most cases it will behave like an object created on runtime.

    • if two literals are identical, only one object will be created and live forever
    • if you create NSString *string = [[NSString alloc] initWithString:@"My String"]; with @"My String" being used as a literal before, also string can point to it.

    Since Apple LLVM Compiler 4.0 Objective-C knows some more literals. But in contrast to string literals these literals are created during runtime through convenient initializers.


    Note that

    [someString stringByAppendingFormat:  @"some text = %d", 3];
    

    does not change someString. It returns a new string object.

    NSString *newString = [someString stringByAppendingFormat:  @"some text = %d", 3];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently trying to learn Android. Have been reading tutorials and manual for
Im currently trying to learn some stuff about encryption, it's algorithms and how it
I'm trying to learn C++ currently, but I'm having issues with the code below.
I'm currently trying to learn Cocoa/Objective-C to build Mac OS X softwares. I come
I'm currently trying to learn BackboneJS and the stuff which comes along, but i
I am currently trying to learn some more in depth stuff of file formats.
I'm currently trying to learn regular expressions with some simple "real world" examples. Take
I'm currently learning objective c and I'm trying to write some simple apps to
I am currently trying to learn J2ME and build a connect four game (some
I'm currently trying to learn Knockout.JS - I'm also relatively new to JavaScript itself.

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.