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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:56:46+00:00 2026-05-21T05:56:46+00:00

I think that I am a bit confused about iOS @property getter and setters.

  • 0

I think that I am a bit confused about iOS @property getter and setters. I am trying to set an NSString iVar in my AppDelegate.h file from another class so that it can be used by all of the classes in the project?

For example, I am working on an iPhone project that stores an iVar NSString *currentUser in AppDelegate.h. I need to be able to set this through one method in a ViewController.m and then get it through another method in a second ViewController?

Maybe Getter and Setter is the wrong direction of attack all together? I understand that i don’t want to alloc init the AppDelegate as the iVar will only exist in that object and I want it accessible to ALL objects in ALL classes?

Please someone set me straight.

All the best,
Darren

  • 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-21T05:56:47+00:00Added an answer on May 21, 2026 at 5:56 am

    Here’s the setup for the app delegate.

    @interface AppDelegate
    {
       NSString *__currentUser;
    }
    @property (monatomic, copy) NSString* currentUser;
    @end
    
    @implementation AppDelegate
    @synthesize currentUser = __currentUser;
    
    - (void) dealloc
    {
       [__currentUser release];
       [super dealloc];
    }
    @end
    

    From one view controller, you could set a value for the current user, and from a subsequent view controller, get that value for some nefarious purpose.

    @implementation LoginController
    - (void) viewDidLoad
    {
        ...
        AppDelegate *bob = [[UIApplication sharedApplication] delegate];
        [bob setCurrentUser: @"Jim Kirk"];
        ...
    }
    @end
    

    In some other view controller that appears later, the value of the current user can be accessed.

    @implementation ProfileViewController
    - (void) viewDidLoad
    {
       ...
       AppDelegate *bob = (AppDelegate *)[[UIApplication sharedApplication] delegate];
       NSString * user = [bob currentUser];
    
       // insert nefarious purpose for current user value here
       ...
    }
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a bit confused about the laws applied to web fonts. I know that
I am a bit confused about this. I have an R package that has
I have a question that I am a little bit confused about. I am
I am a bit confused about the size of icon that appears in app
just think that when I opened my file then when I want to write
I'm using SQLite as my database, and I'm a little bit confused about how
I'm bit confused about how the global variables work. I have a large project,
I am confused about Windows BSTR's and WCHAR's, etc. WCHAR is a 16-bit character
I am a bit confused about the service layer and using it validation. So
I am porting some Haskell code to F# but a bit confused about the

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.