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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:06:24+00:00 2026-05-27T22:06:24+00:00

I actually feel a little embarrassed asking this because it feels about as basic

  • 0

I actually feel a little embarrassed asking this because it feels about as basic as you can go, but it’s been stumping me for hours…

Let’s say I have an instance of a UIViewController (called MyViewController) which simply has one IBOutlet to a UITextField, and when the page loads I either set it to be Enabled or not based on a BOOL property.

- (void)viewDidLoad {
    [super viewDidLoad];
    self.surname.enabled = self.allowTextField;
}

Everything is wired up correctly and when I run the app it works as expected (lord – I’d hope so cause if I couldn’t get that part right, I probably shouldn’t be writing iPhone apps…).

Anyway, I decided to be diligent and write application Unit Tests for the app because it’s something I want to become a lot more solid in. Unfortunately, I cannot for the life of me understand why the following does not work…

-(void)testFieldEnabled {
    MyViewController *myController = [[MyViewController alloc] initWithNibName:nil bundle:nil];
    myController.allowTextField = YES;
    [myController viewDidLoad];
     STAssertTrue(myController.surname.enabled, @"Why is this not correct?");
}

I’ve kept this example extremely simple because I truly don’t get why this is not working and believe it must be due a major failing in my understanding of unit testing. Shouldn’t the above unit test fire-up an instance of MyViewController page, set the property, run the method and return true? At the moment it keeps telling me that the surname textfield is not enabled.

Thanks for your help and a happy new year to you all!

  • 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-27T22:06:25+00:00Added an answer on May 27, 2026 at 10:06 pm

    This is because calling viewDidLoad manually doesn’t actually load the view. You should call view property of the view controller, which will load the view automatically (or call loadView manually).

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

Sidebar

Related Questions

I feel like I'm missing something basic, and I'm actually kind of embarrassed asking
Disclaimer: This is not actually a programming question, but I feel the audience on
This question has been asked before, but I would like a little more detail
I know there are several question like this one but I feel I've spent
I've been working a little with DevExpress CodeRush and Refactor! Pro this week, and
I feel a bit stupid as i can't find the answer to this question,
this is actually a follow up to a question I asked yesterday about problems
I know I know this has been posted millions of times but I still
I feel a bit silly for asking what I'm sure is a rather basic
I feel like this question has already been asked and answered, yet I couldn't

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.