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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:40:28+00:00 2026-05-11T16:40:28+00:00

Hi i’ve got the following code in a ViewController.h: #import <UIKit/UIKit.h> @interface CalcViewController :

  • 0

Hi i’ve got the following code in a ViewController.h:

#import <UIKit/UIKit.h>

@interface CalcViewController : UIViewController {
    NSNumber* result;
    NSString* input;
    //NSString* input = @"";

    IBOutlet UITextField* display;
}

@property (retain) NSNumber* result;
@property (retain) NSString* input;
@property (nonatomic, retain) UITextField* display;

@end

The problem is that I want to append a string to input but this is not possible when its still null. Thats why I want to set the default value of input to be @””. But where do I put this code.

I’m aware of one possible solution where you put it in a default constructor. But I’ve got no idea in what file to put this. And where I should call it from.

I unfortunately only got a limited understanding of C and realise that perhaps a .h file is not the right place.

The project type is a View-Based-Application if you should need this.

Hope you can help.

  • 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-11T16:40:29+00:00Added an answer on May 11, 2026 at 4:40 pm

    You may find it useful to read some documentation on Objective-C or Cocoa. You probably can find some good suggestions on reading material if you perform a search here in StackOverflow or on Google.

    To answer your question, you should have a @implementation of CalcViewController. One would most often place this @implementation inside of the *.m file. If your *.h file is named “ViewController.h” then the implementation would go in “ViewController.m”.

    You would then create a copy of the UIViewController’s initialization function and place it there (I don’t know what the default init function is).

    For example:

    @implementation CalcViewController
    
    @synthesize result;
    @synthesize input;
    
    - (id)initWithNibName:(NSString*)aNibName bundle:(NSBundle*)aBundle
    {
        self = [super initWithNibName:aNibName bundle:aBundle]; // The UIViewController's version of init
        if (self) {
            input = [[NSString alloc] initWithString:@""]; // You should create a new string as you'll want to release this in your dealloc
        }
        return self;
    }
    
    - (void)dealloc
    {
        [input release];
        [super dealloc];
    }
    @end // end of the @implementation of CalcViewController
    

    NOTES:

    • You may want to rename the file to CalcViewController. I believe it is easier for Xcode’s refactoring engine to deal with.
    • You do not need to declare the @property for the display instance variable as you connect that with Interface Builder. Unless you want clients of the CalcViewController to change it often

    EDIT: April 28, 2009: 10:20 AM EST: I suggest actually allocating a NSString as you should technically release it in the dealloc.

    EDIT: April 28, 2009: 11:11 AM EST: I updated the @implementation to use the UIViewController’s version of init.

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

Sidebar

Ask A Question

Stats

  • Questions 210k
  • Answers 210k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Java would be the way to go if you're wanting… May 12, 2026 at 9:53 pm
  • Editorial Team
    Editorial Team added an answer We can't guess what you are trying to do, nor… May 12, 2026 at 9:53 pm
  • Editorial Team
    Editorial Team added an answer The usual Python style is the first approach. For example,… May 12, 2026 at 9:53 pm

Related Questions

Hi I am trying to deploy an application using webstart. I have a requirement
Hi i need to generate 9 digit unique account numbers. Here is my pseudocode:
Hi i want to write a game with a main game form and lot
Hi I'm trying to debug a stored procedure through SQL Analyzer and one of
Hi I'd like to schedule an existing job in the Sql Server 2005 agent

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.