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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:22:55+00:00 2026-05-26T13:22:55+00:00

In this snippet: NSString *testString; testString = [[NSString alloc] init]; Why, on the second

  • 0

In this snippet:

NSString *testString; 
testString = [[NSString alloc] init]; 

Why, on the second line, do we not have to write *testString = ... in order to access the location where it’s actually pointing?

After the first line, what is *testString and what is testString?

  • 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-26T13:22:56+00:00Added an answer on May 26, 2026 at 1:22 pm

    Why, on the second line, do we not have to write *testString = ... in order to access the location where it’s actually pointing?

    The init method returns a generic pointer to an object — its return type is id. testString is a pointer to an NSString, which is an object, so you are assigning a pointer to another pointer. Dereferencing the assigned-to pointer would be a type mismatch.

    A variable name is a place (a label for a memory address) in which to put something. The type of the variable is the kind of thing that you can put there. In the case of a pointer, the kind of thing that you put in it is also a memory address. In order to get that address, you dereference the pointer. The kind of thing that you can put at that address is different from the kind that you put in the pointer itself.

    After the first line, what is *testString and what is testString?

    After the first line, *testString, or the thing at which testString points, is garbage (actually undefined). testString is a pointer (4 or 8 bytes depending on your system) to a address in memory, and it is also undefined.

    After the second line, *testString is an NSString object. testString is still a pointer to an address, where there is a valid NSString object.

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

Sidebar

Related Questions

I have this code snippet, NSString *number = [NSString stringWithFormat:@tel://%@, phoneNumber]; NSLog(@%@, number); [[UIApplication
This snippet works well if I try to write in a user directory but
This snippet of code always parses the date into the current timezone, and not
Not sure why one snippet works while the other fails: This fails(the app quits)
I have a simple question about nsxmlparser . This is my snippet - (void)
I have the following code snippet in my Xcode: NSString *digit [[sender titlelabel] text];
Quick one folks. Have a quick look at the code snippet below. I alloc
I frequently see a code snippet like this in class instance methods: static NSString
This snippet of Perl code in my program is giving the wrong result. $condition
This snippet throws an NullPointerException due to the fact that its unboxed to a

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.