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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:33:23+00:00 2026-06-12T06:33:23+00:00

It’s stepping into the ViewDidLoad of the main view controller, and hitting the line

  • 0

It’s stepping into the ViewDidLoad of the main view controller, and hitting the line calling get all tweets, but I put a breakpoint in the getAllTweets of both the base and derived to see if it just wasn’t hitting the derived like I expected.

@implementation WWMainViewControllerTests {

    // system under test
    WWMainViewController *viewController;

    // dependencies
    UITableView *tableViewForTests;
    WWTweetServiceMock *tweetServiceMock;    
}

- (void)setUp {

    tweetServiceMock = [[WWTweetServiceMock alloc] init];
    viewController = [[WWMainViewController alloc] init];
    viewController.tweetService = tweetServiceMock;
    tableViewForTests = [[UITableView alloc] init];
    viewController.mainTableView = tableViewForTests;
    tableViewForTests.dataSource = viewController;
    tableViewForTests.delegate = viewController;
}

- (void)test_ViewLoadedShouldCallServiceLayer_GetAllTweets {

    [viewController loadView];
    STAssertTrue(tweetServiceMock.getAllTweetsCalled, @"Should call getAllTweets on tweetService dependency");
}

- (void)tearDown {

    tableViewForTests = nil;
    viewController = nil;
    tweetServiceMock = nil;
}

The base tweet service:

@implementation WWTweetService {

    NSMutableArray *tweetsToReturn;
}

- (id)init {

    if (self = [super init]) {
        tweetsToReturn = [[NSMutableArray alloc] init];
    }

    return self;
}
- (NSArray *)getAllTweets {

    NSLog(@"here in the base of get all tweets");
    return tweetsToReturn;
}

@end

The Mock tweet service:

@interface WWTweetServiceMock : WWTweetService

@property BOOL getAllTweetsCalled;

@end

@implementation WWTweetServiceMock

@synthesize getAllTweetsCalled;

- (id)init {

    if (self = [super init]) {
        getAllTweetsCalled = NO;
    }

    return self;
}

- (NSArray *)getAllTweets {

    NSLog(@"here in the mock class.");
    getAllTweetsCalled = YES;
    return [NSArray array];
}

The main view controller under test:

@implementation WWMainViewController
@synthesize mainTableView = _mainTableView;
@synthesize tweetService;

NSArray *allTweets;

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    allTweets = [tweetService getAllTweets];
    NSLog(@"was here in view controller");
}

- (void)viewDidUnload
{
    [self setMainTableView:nil];
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}
  • 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-06-12T06:33:24+00:00Added an answer on June 12, 2026 at 6:33 am

    Since you’re able to break in the debugger in viewDidLoad, what’s the value of the tweetService ivar? If it’s nil, the getAllTweets message will just be a no op. Maybe the ivar isn’t being set properly or overridden somewhere else.

    You should probably use the property to access the tweetService (call self.tweetService) rather than its underlying ivar. You should only ever access the ivar directly in getters, setters, and init (also dealloc if aren’t using ARC for some crazy reason).

    You also should not call loadView yourself, rather just access the view property of the view controller. That will kick off the loading process and call viewDidLoad.

    Also, if you’re doing a lot of mocking, I highly recommend OCMock.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I want to count how many characters a certain string has in PHP, but
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I have a text area in my form which accepts all possible characters from
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;

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.