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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:24:05+00:00 2026-05-28T01:24:05+00:00

I have an NSInteger in my app delegate called healthInt. In the app delegate

  • 0

I have an NSInteger in my app delegate called healthInt. In the app delegate i have healthInt set to 100. And when the application loads the first view healthInt is still equal to 100. But when it loads the next view, healthInt is set to 0. Even though a label in that view controller (titled healthLabel) displays 100. The reason this is a problem is because what i wanna do is

-(void)viewDidLoad{
   if(appDelegate.healthInt <= 0){
   healthLabel.text = @"Dead";
  }
}

But this doesn’t seem to work. And i know this is bad architecture but it’s a bit too late for me to redo the entire project. If you need to see other code i’ll be happy to show it to you 🙂

  • 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-28T01:24:05+00:00Added an answer on May 28, 2026 at 1:24 am

    I agree with the comment. Make sure that you appDelegate property isn’t null. If it is you can use

    id<UIApplicationDelegate> appDelegate = [UIApplication sharedApplication].delegate 
    

    to get it again.

    [Edit]
    You will have to cast the appDelegate to your class type to get “healthInt” from the delegate.

    MyAppDelegate *myApp = (MyAppDelegate *)[UIApplication sharedApplication].delegate
    

    [2nd Edit]
    DUH! I didn’t see your example code was in your viewDidLoad. Hot Licks is right. You need to set the delegate in the view controller before you can call it.

    Try this:

    -(void)viewDidLoad{
    
    appDelegate = [[UIApplication sharedApplication] delegate];
         if(appDelegate.healthInt <= 0){
         healthLabel.text = @"Dead";
        }
        }
    

    Hope this helps.

    Rob

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

Sidebar

Related Questions

I am currently writing my first iPhone app, but have encountered an issue. I
I have a view based application and a UITableview in the view. I set
I try to use the UIActionSheet within my iPhone App but have the following
I have a Tab Bar with a navigation table view. My app crashes when
I have a method in my app delegate that updates the badge count for
I have integrated Google mobile analytics into my iphone app, but for some reason
I have a UIAlertView with the following delegate method: - (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex {
I have a UIPickerView, in it's delegate I'm trying to customize the view for
I have in my App Delegate an NSArray that contains a range of LPProduct
I have a counter in my app that has a reset button, but instead

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.