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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:43:20+00:00 2026-05-12T10:43:20+00:00

I am using a variable/propery of my application delegate as a global. (I don’t

  • 0

I am using a variable/propery of my application delegate as a global. (I don’t want to deal with a singleton class.)

I am trying to write a #define statement in my Application Delegate class. If I type:

  [UIApplication sharedApplication]

in my app delegate class, code hinting does not recognize sharedApplication. But if I type the same thing in a viewController class, “sharedApplication” pops right up.

In order to define a NSMutableDictionary in my applicationDelegate.h (or .m?), I write:

#define MyDictionary [[[UIApplication sharedApplication] delegate] stateDictionary]

Then if I try to use it in another class:

[[MyDictionary objectForKey:@"California"] largestCity];

I get an error that MyDictionary must be declared first. I am really confused about a lot of concepts here.

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

    I’m pretty sure that someone will answer this better, but here’s a quick one:

    Let’s say your application is called myApplication. Assign “global” property to MyApplicationDelegate, and then it will be accessible from anywhere like this:

    // get reference to app delegate
    MyApplicationDelegate *appDelegate = (MyApplicationDelegate *)[[UIApplication sharedApplication] delegate]
    
    Property *myProperty = appDelegate.property;
    

    Also, make sure that you link to MyApplicationDelegate file in header:

    #import "MyApplicationDelegate.h"
    

    There’s a longer debate if using “global” objects is good design in general, but I won’t go into that now.

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

Sidebar

Related Questions

How do I widen the cope of a variable using ReSharper? from: public class
I am trying to call ssh-keygen using a variable through bash as an input
I am trying to get some xpath from xsl variable using xsl ver 1.0
I am building web application using Spring MVC Spring Security Hibenate MySQl I want
When I add a comment using the variable below, apostrophes are printed with a
Is it possible to declare more than one variable using a with statement in
hello frieds this is how i usually post a variable using Jquery.. $.post(include/save_legatee.inc.php, {
In php, I often need to map a variable using an array ... but
I'm using a GET variable and people get to it by the following URL:
I am using a Session variable to pass a datatable from 1 page to

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.