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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:40:26+00:00 2026-06-07T05:40:26+00:00

I have a textViewController class. I want to set(basically update) the corresponding textView’s content

  • 0

I have a textViewController class. I want to set(basically update) the corresponding textView’s content from another view controller which I am pushing over the present textViewController. The way I thought I could do this was to have a shared singleton class and have a string property there to contain the text. I have been using the singleton for storing some other content as well and it worked fine till now.


But the text variable in singleton class doesn’t hold the content I pass to it from the second view controller and hence the textViewController, after popping the second view controller, displays the old text even after reappearing. I am updating the textView in its viewWillAppear method which is getting called but shows old text content on NSLogging.
What am I missing here? Please suggest a solution, stuck at it for a long time now.

  • 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-07T05:40:26+00:00Added an answer on June 7, 2026 at 5:40 am

    Declaration

    Firstly, declare the NSString in your app delegate .h file. It should look something like this:

    //YourAppDelegate.h
    
    #import <UIKit/UIKit.h>
    
    @interface YourAppDelegate : NSObject < UIApplicationDelegate >
    {
        NSString *sharedString; //WE ADDED THIS
    }
    
    @property (nonatomic, retain) NSString *sharedString; //AND THIS
    @property (nonatomic, retain) IBOutlet UIWindow *window;
    @property (nonatomic, retain) IBOutlet SomeViewController *viewController;
    
    @end
    

    Now you want to synthesize the object so that the accessor and mutator methods are made for you. This means you don’t have to write the setSharedString: and getSharedString methods – we can simply access and mutate the object by making a reference to it. This is how we synthesize it in the .m file:

    //YourAppDelegate.m
    @synthesize sharedString;
    

    Assigning a Value

    When you want to assign a value to sharedString from another class, you must first retrieve the active instance of your application delegate:

    YourAppDelegate *appDelegate = (YourAppDelegate*)[[UIApplication sharedApplication] delegate];
    

    The appDelegate object here is your running app delegate instance. To access the sharedString NSString object in the delegate and assign a value, we’d do this:

    appDelegate.sharedString = @"some string we want to assign";
    

    For the duration of our application’s runtime, “some string we want to assign” is now stored in sharedString in our app delegate.

    Retrieving the Value

    You’ll want to retrieve the value at some point. To do this, again we’ll have to get the running instance of our application delegate:

    YourAppDelegate *appDelegate = (YourAppDelegate*)[[UIApplication sharedApplication] delegate];
    

    Once we have the running instance, we can then access the sharedString object stored inside it:

    NSString *retrievedString = appDelegate.sharedString;
    

    From this point, retrievedString now holds the value “some string we want to assign“.

    Note:

    Everywhere I mention YourAppDelegate, I am referring to your app delegate – the app delegate you have in your project. It’ll be related to your project name (look for the file).

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

Sidebar

Related Questions

i have a method that call another method with 1 parameter to another class.
Have one Doubt In MVC Architecture we can able to pass data from Controller
I have created a UITextField along with UIPickerView programmatically and set the input view
I have a TextViewController which is a subclass of NSViewController which controls a View
Have following setup: MainActivity class - extends activity MyLayout class - extends View Prefs
have written this little class, which generates a UUID every time an object of
Have deployed numerous report parts which reference the same view however one of them
have a nice day. I got problem when trying to create an image from
I have a TTLauncherView with some TTLauncherItems . These show badges, representing messages from
If I have a custom class called Tires: #import <Foundation/Foundation.h> @interface Tires : NSObject

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.