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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:23:38+00:00 2026-05-26T13:23:38+00:00

I have an iOS app built since the beginning with an error in it.

  • 0

I have an iOS app built since the beginning with an error in it. Since the source was began constructed from the template, its appdelegate.h looks like:

@interface myAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
    myViewController *viewController;
}

BOOL       myBool;     // intended to be globally accessible
NSString   *myString;  // intended to be globally accessible

@end

I refer to myBool and *myString from many other .m source files, as to global variables.

Below XCode 3.2.6, I can not remember getting any issues at compile time.

At 3.2.6, warning appeared at compile pointing to these “global” variables in appdelegate.h, saying: “Cannot declare variable inside @interface or @protocol”. As there were no further problems with compilation or during app runtime, unfortunately I did not consider these warnings.

Now, using XCode 4.2, I am unable to compile this source, because the former warnings turned into build errors. They refer and point to each of those lines in the different .m files where there is a reference to the “global variables”.

Is there an easy way to correct this problem, considering that I still want to access these variables/references as global ones?

Additional question: while I am evaluating so far received answers (thanks for all of you), another question: any idea why no warning were given below XCode v3.2.6, and only warnings in 3.2.6 if this is a real error from my side? And why the code was still compiled and could be run without any problem?

  • 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-26T13:23:38+00:00Added an answer on May 26, 2026 at 1:23 pm

    They can’t go there. You can put them inside the curly braces {} like this:

    @interface myAppDelegate : NSObject <UIApplicationDelegate> {
        UIWindow *window;
        myViewController *viewController;
    BOOL       myBool;     // intended to be globally accessible
    NSString   *myString;  // intended to be globally accessible
    }
    
    @end
    

    And that makes them global to the implementation class. But if you want them global to every class in your app then you should drop them in your App-Prefix.pch file:

    //
    // Prefix header for all source files of the ... project
    //
    #import <Availability.h>
    BOOL       myBool;     // intended to be globally accessible
    NSString   *myString;  // intended to be globally accessible
    #ifndef __IPHONE_3_0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using OpenCV 2.2 compiled and built from source for iOS. I used
I have built an iOS app which I would now like to test converting
We have an app that has crashed on armv6 iOS devices coming from the
I have an iOS 4.3 iPhone app built in Xcode4 that I'm submitting through
I have built an iOS app that leverages Core Location Framework. I have Xcode
I have a test app for iOS that is built without any nib/xib files.
I have an application that has been running fine since its launch over a
I'm running Xcode 3.2.3 with the iOS 4.0 SDK. I built my app with
I have an iOS app where you can drag many images and rotate them.
I have this code in my iOS app: - (IBAction)cameraButtonPressed:(id)sender { if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]

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.