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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:40:16+00:00 2026-05-21T10:40:16+00:00

I am trying to do the following – (void)textViewDidChange:(UITextView *)textView{ if(textView == txtYourTip){ if([txtYourTip.text

  • 0

I am trying to do the following

- (void)textViewDidChange:(UITextView *)textView{
if(textView == txtYourTip){
    if([txtYourTip.text length] < 100){
        strTip = txtYourTip.text;
        NSLog(@"%@",strTip);
    } else {
        NSLog(@"%@",strTip);
        txtYourTip.text = strTip;
    }}

Application crashes when controls goes to else part. strTip is of type NSString.

viewDidLoad contains

    txtYourTip = [[UITextView alloc] initWithFrame:CGRectMake(15, 80, 290, 80)];
[txtYourTip.layer setBorderColor:[[UIColor lightGrayColor] CGColor]];
[txtYourTip setDelegate:self];
[txtYourTip setContentInset:UIEdgeInsetsMake(10, 10, 10, 10)];
txtYourTip.layer.cornerRadius = 10.0;
[txtYourTip.layer setBorderWidth:2.0];
[contentView addSubview:txtYourTip];

strTip = [[NSMutableString alloc] init];

  • 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-21T10:40:16+00:00Added an answer on May 21, 2026 at 10:40 am

    If you put the strTip = @”” in viewDidLoad like you said I think that is the reason.
    Allocating a NSString with @”a text” is making it autoreleased. So at some point the data is released but the pointers points to it. When you try to display it you have an exception.

    Try this in your viewDidLoad :
    strTip = [[NSString alloc] init];
    or

    strTip = @"";
    [strTip retain];
    

    Either one should work and will need a :

    [strTip release];
    strTip = nil;
    

    in the view viewDidUnload so you don’t leak

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

Sidebar

Related Questions

I'm trying the following code: int length = SendMessage(textBoxPathToSource, WM_GETTEXTLENGTH, 0, 0); LPCWSTR lpstr;
I am trying to set custom error messages for invalid length of the following
I was trying the following example, but with external URLs: Using WebViews The example
I am trying the following code: <?php $link = mysql_connect('localhost', 'root', 'geheim'); if (!$link)
I'm new to Ruby, and I'm trying the following: mySet = numOfCuts.times.map{ rand(seqLength) }
I'm trying out the following query: SELECT A,B,C FROM table WHERE field LIKE 'query%'
I've ran into a problem while trying to test following IRepository based on NHibernate:
I'm following several tutorials and references trying to get my kernel set up. I've
I'm trying to get the following bit of code to work in LINQPad but
I'm trying to bind the following shortcut: Ctrl + W to close tabs How

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.