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

The Archive Base Latest Questions

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

I apologise if this is a bad question as I’m new to iOS development.

  • 0

I apologise if this is a bad question as I’m new to iOS development. So here is my problem: I declared a class variable NSString, the string is assigned a string value from a textView but when i try to access the string from other method, the app crashes. Here’s the code:

Interface: (ClassName.h)

@interface ClassName: UIViewController <UITextViewDelegate>{}
@property (nonatomic, assign)NSString *strSomeText;
@end

Implementation: (ClassName.m)

@implementation
@synthesize strSomeText;
- (void)textViewDidChange:(UITextView *)textView{
    strSomeText = textView.text;
    NSLog(@"%@", strSomeText); //This line works just fine
}
- (void)textViewDidEndEditing:(UITextView *)textView{
    NSLog(@"%@", strSomeText); //this line causes the app to crash
}
@end

Thanks for the help!
Loc.

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

    Your problem is likely due to the fact that you’re using assign for your property. This will mean that the string can be deallocated while you still have a reference to it. Try using copy instead:

    @property (nonatomic, copy) NSString *strSomeText;
    

    Then you should use your property accessor in your textViewDidChange: method:

    self.strSomeText = textView.text;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is probably a very simple question, I apologise - I'm new to rails.
I am fairly new to this and I do apologise if this is a
I'm reasonably new to using SQL, so I apologise if this is a newbish
Before I ask this question I would to apologise because of the fact that
I appreciate this question is a little silly, so I apologise in advance if
I apologize in advance for the newbie nature of this question. Here is my
First : Appologize for my bad english. Sorry for this newbie software question, but
I apologise for the blatant ignorance of this question but I've been charged with
I've looked around a little and haven't found an equivalent question. Is this bad
I'm new to rails and apologize if this is a n00b question. I'm making

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.