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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:18:59+00:00 2026-05-13T08:18:59+00:00

Is NSInvocation class not meant to be called via unit tests (for iPhone)? My

  • 0

Is NSInvocation class not meant to be called via unit tests (for iPhone)?

My intent is to call a class’s method generically and since the method has more than 2 parameters, I can’t use [myTestClass performSelector:withObject:withObject]

Instead, I’m trying to use NSInvocation but as soon as I try to instantiate from NSInvocation class, I get the build error:

2009-12-31 11:12:16.380
otest[2562:903] ******* ABOUT TO CALL
NSInvocation
/Developer/Tools/RunPlatformUnitTests.include:
line 415: 2562 Bus error
“${THIN_TEST_RIG}”
“${OTHER_TEST_FLAGS}”
“${TEST_BUNDLE_PATH}”
/Developer/Tools/RunPlatformUnitTests.include:451:
error: Test rig
‘/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/
iPhoneSimulator3.1.2.sdk/Developer/usr/bin/otest’
exited abnormally with code 138 (it
may have crashed).

My class under test:

@implementation MyExampleClass
-(void)methodWithArgs:(NSString *)aValue 
          secondParam:(NSString *)aSecond 
          thirdParam:(NSString *)aThird
{
    NSLog(@"methodWithArgs reached");
}
-(void)methodBlank
{
    NSLog(@"methodBlank reached");
}
-(void)isTesting
{
    NSLog(@"isTesting reached");
}
@end

My unit test:

@interface MyClassTests : SenTestCase
{
}    
@end

@implementation MyClassTests

- (void)testNSInvocation
{   
    Class probeClass = NSClassFromString(@"MyExampleClass");
    if (probeClass != Nil) {        
      SEL selector = NSSelectorFromString(@"isTesting");

      NSMethodSignature *sig = [probeClass methodSignatureForSelector:selector];

      // the following line causes the error
      NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:sig];  

      // this variation also fails
      NSMethodSignature *sig2 = [probeClass 
      methodSignatureForSelector:@selector(methodWithArgs:secondParam:thirdParam:)];

      NSInvocation *inv2 = [NSInvocation invocationWithMethodSignature:sig2];   
    }   
}
@end

What’s a way to invoke a method with more than 2 parameters at run-time? Do I have to change the signature of the method so it only has 2 params? Is this a limitation of the unit-test framework?

  • 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-13T08:18:59+00:00Added an answer on May 13, 2026 at 8:18 am

    The reason the above is failing is indeed due to an incorrect selector.

    Instead of using “methodSignatureForSelector“, I needed to specify: “instanceMethodSignatureForSelector“

    since the methods are instance methods.

    However, both of your answers were helpful in tracking down the issue.

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

Sidebar

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.