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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:25:04+00:00 2026-06-06T03:25:04+00:00

I have an NSString declared like this : .h: @interface ViewController : UIViewController {

  • 0

I have an NSString declared like this :

.h:

@interface ViewController : UIViewController

{

        NSString * aString;

}
@property(nonatomic,copy)NSString *aString;

.m :

@synthesize aString;

......

aString=[[NSString alloc]init];
aString=@"Hello World";

NSLog(@"%@",aString);//The app crashes here

The app crashes with this stack trace:

-[CFString respondsToSelector:]: message sent to deallocated instance
  • 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-06T03:25:07+00:00Added an answer on June 6, 2026 at 3:25 am

    remove the line:

    aString=[[NSString alloc]init];
    

    and set values to the property:

    self.aString=@"Hello World";
    

    Doing: aString=@"Hello World"; means you are setting value to the instance variable, without using the accessor methods of the property, then you are responsible to the memory management and it’s more complicated. Get the value by: self.aString also.
    P.S. Always work though properties, almost never use the instance variables, (only in the dealloc method release the ivar, otherwise if you are not good at memory management you will always have problems, but properties do everything for you)

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

Sidebar

Related Questions

I have three NSString properties declared like this: @property(nonatomic,retain) NSString *currentPassword; @property(nonatomic,retain) NSString *newPassword;
I have an NSString declared as @property (nonatomic,copy) NSString *text in a class. When
I have declared this ivar in my ViewController.h #import <UIKit/UIKit.h> @interface FirstViewController : UIViewController
I have a NSString declared in the interface part: @property (nonatomic, retain) NSString *filePath;
Let's say that I have declared an NSString like this NSString *myString = [[NSString
I have a bunch of constants declared like this: #define kConstant0 @Cow #define kConstant1
I have declared the UIAlertViewDelegate to call its methods like this way -(IBAction)hidding{ [self
I have NSString like My name is. I want to remove text after coming
I have a NSString object having multiple conditions specified in it like below: NSString
I have an NSString that I'd like to append a { at the beginning

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.