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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:28:40+00:00 2026-06-06T02:28:40+00:00

On my app delegate class I have a simple property @property (strong, nonatomic) LoginAppDelegate

  • 0

On my app delegate class I have a simple property

@property (strong, nonatomic) LoginAppDelegate *loginAppDelegate;

I then offload the app delegate like functionality for all login views here so I can keep my main app delegate class small (ish)

Then on the login app delegate I have a method to push a view controller on the main navigation controller

- (void)launchSomeOtherViewController {} 

The painful part is when I’m inside a view controller that invokes this “launch” method

- (void)callBackAfterSomeHttpMethodLetsSay
{
    [self.appDelegate.loginAppDelegate launchSomeOtherViewController];
}

When I try to mock this out it appears my stub on the app delegate isn’t correct

- (void)testCallBackWithSignupTokenInvokesLaunchCompleteSignupViewControllerWithToken
{
    id mockLoginAppDelegate = [OCMockObject mockForClass:[LoginAppDelegate class]];
    id mockAppDelegate = [OCMockObject mockForClass:[AppDelegate class]];
    [[[mockAppDelegate stub] andReturn:mockLoginAppDelegate] loginAppDelegate];
    [[mockLoginAppDelegate expect] launchSomeOtherViewController];
    [self.sut callBackAfterSomeHttpMethodLetsSay];
    [mockLoginAppDelegate verify];
}

The error when I run this via ocunit is the usual “expected method was not invoked”

So my question is related to the way I’m stubbing this -can I do a stub that returns the login mock as I have or do I need to reach into the getter manually?

  • 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-06T02:28:42+00:00Added an answer on June 6, 2026 at 2:28 am

    It looks like you’re not making your mockAppDelegate visible to the class under test. Try adding:

    [self.sut setAppDelegate:mockAppDelegate];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a simple app using the AsynUDPSocket class. It listens to simple
I have defined a UIWebViewDelegate class and instantiated it in the Delegate property of
I have a simple class which does reverse geocoding, but it causes the app
I have this method in App Delegate that makes a window and content view
I have an array of users in my app delegate, and in one of
I'm writing a Cocoa application where I have an auto generated app delegate:(MyAppDelegate.h/MyAppDelegate.m) So
My iPhone app is quite simple, however it errors out. My app delegate opens
I have a very simple class called Profile. It contains NSMutableArray called avatar which
I have a Core Data app with a fairly simple data model. I want
All this might look too trivial but read it through - I have simple

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.