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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:07:33+00:00 2026-05-23T04:07:33+00:00

I’m trying to create a simple Quiz app (I’m a beginner), when I launch

  • 0

I’m trying to create a simple Quiz app (I’m a beginner), when I launch the app I want a UILabel to show the first question (of an array of questions). I’m having some trouble with setting the initial value.

I’ve done a couple of attempts, whiteout success. I my QuizAppDelegate.h file I declare my UILabel like this:

 IBOutlet UILabel * questionField;

In my main .m file I have tried the following:

- (id)init {

    [super init];

    questions = [[NSMutableArray alloc] init];

    // Not working
    questionField = [[UILabel alloc] init];
    [questionField setText:@"Hello"];

    // Working
    NSLog(@"Hello");

    [self defaultQuestions];
    // [self showQuestion];

    return self;
}

Another thing I have tried is the following in QuizAppDelegate:

@property (nonatomic, retain) IBOutlet UILabel *questionField;

- (void)changeTitle:(NSString *)toName;

And in the .m file:

@synthesize questionField;

- (id)init {

    [super init];

    questions = [[NSMutableArray alloc] init];

    // Not working
    [self changeTitle:@"Hello"];

    // Working
    NSLog(@"Hello");

    [self defaultQuestions];
    // [self showQuestion];

    return self;
}

-(void)changeTitle:(NSString *)toName {
    [questionField setText:toName];
}

Any tips on how to solve this would be great!

// Anders

  • 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-23T04:07:33+00:00Added an answer on May 23, 2026 at 4:07 am

    Hopefully you’re not actually putting code into main.m. On iOS, you rarely modify that file.

    Since you’re doing everything in the AppDelegate, let’s keep it there (as opposed to creating a new UIViewController). Let’s start with the basics.

    Adding the Label as an instance variable

    You’re doing this correctly—inside the curly braces of the .h file, put the line

    IBOutlet UILabel * questionField;
    

    Then, declare the corresponding property, and make sure to synthesize it in the .m file.

    @property (nonatomic, retain) IBOutlet UILabel *questionField;
    @synthesize questionField    // in the .m file
    

    Adding the UILabel in Interface Builder

    Open up MainWindow.xib. Drag a UILabel from the Library to the Window that represents your app’s window. Then Control-Drag from the AppDelegate object (the third icon on the left in Xcode 4; it’ll be labelled in the Document window in IB 3). You’ll see a little black window come up—select the option called questionField to make the connection.

    See this link for screenshots and how to make connections in IB. The same applies in Xcode 4.


    Changing the text

    You don’t need a separate method to change the text—just modify the label’s text property.

    Pick a method that’ll be called when the app launches (applicationDidFinishLaunching:WithOptions: is a good place to do it in), and put the following code:

    questionField.text = @"Hello";
    

    And that’s it!


    Code

    QuizAppDelegate.h

    #import <UIKit/UIKit.h>
    
    @interface QuizAppDelegate : NSObject <UIApplicationDelegate> {
        IBOutlet UILabel *questionField;
    }
    
    @property (nonatomic, retain) IBOutlet UIWindow *window;
    @property (nonatomic, retain) IBOutlet UILabel *questionField;
    
    @end
    

    QuizAppDelegate.m

    #import "QuizAppDelegate.h"
    
    @implementation QuizAppDelegate
    
    @synthesize window=_window;
    @synthesize questionField;
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        // Override point for customization after application launch.
        // Add the tab bar controller's current view as a subview of the window
        [self.window addSubview:self.questionField];
        [self.window makeKeyAndVisible];
        self.questionField.text = @"Hello";
        return YES;
    }
    
    - (void)dealloc
    {
        [_window release];
        [questionField release];
        [super dealloc];
    }
    
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
We're building an app, our first using Rails 3, and we're having to build
I'm making a simple page using Google Maps API 3. My first. One marker
I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have just tried to save a simple *.rtf file with some websites and
I am trying to loop through a bunch of documents I have to put
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.