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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:20:08+00:00 2026-06-13T11:20:08+00:00

I’ve come across this ‘problem’ (it’s not really a problem, I merely was astonished

  • 0

I’ve come across this ‘problem’ (it’s not really a problem, I merely was astonished that that was possible) while trying some things with TabBarController template in Xcode. If you use the template without storyboarding the basic setup looks like this:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
UIViewController *viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
UIViewController *viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
self.tabBarController = [[UITabBarController alloc] init];

self.tabBarController.viewControllers = @[viewController1, viewController2];

self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}

The viewControllers property of the tabBarController is an NSArray. Thus [self.tabBarController objectAtIndex:0] returns an id.

So I always thought if I wanted to call a method I declared at f.e. the FirstViewController class, I had to do it like this:

FirstViewController *firstVC = (FirstViewController *)[self.tabBarController objectAtIndex:0];
[firstVC someMethod];

But as it turned out, that unnecessary, the complier would also let me do the following – AS LONG AS I import a header file which declares someMethod (of course it doesn’t necessarily increase readability, but anyway):

[[self.tabBarController objectAtIndex:0] someMethod];

I wasn’t expecting this at all. So I’m assuming the compiler will allow calling any method on id as long as that method is declared in any class in scope of the current class (by that I mean, it’s header file is imported into the current class). If the class declaring someMethod is not imported, the compiler will throw an error (But I have to add that I tested this while using ARC. It may very well be possible, that the compiler doesn’t complain about calling ‘unimported’ methods on id when not using ARC)…

Is that assumption correct? And if possible could you provide some more information or reference about the id type?

Or did the compiler allow calling any method on id (imported or not) before ARC, and the complaint now for unimported methods is just a result of ARC?

Thx alot.

  • 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-13T11:20:09+00:00Added an answer on June 13, 2026 at 11:20 am

    Or did the compiler allow calling any method on id (imported or not) before ARC, and the complaint now for unimported methods is just a result of ARC?

    This is correct. Without ARC it was a warning. With ARC, it’s an error (because ARC can get into serious problems if it guesses wrong here).

    In some cases this behavior can cause some very subtle bugs with or without ARC. If there are multiple method signatures that match the selector, then the compiler may choose the wrong return type, and this can cause very surprising runtime behavior. Matt Gallagher provides a very good explanation of this in “A big weakness in Objective-C’s weak typing.” I’ve encountered the same bug he’s describing, and it’s something ObjC developers should be aware of even though it doesn’t come up that often.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I know there's a lot of other questions out there that deal with this
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.