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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:01:29+00:00 2026-05-25T16:01:29+00:00

@interface Foo : NSObject { } – (Bar)bar; At runtime, given [Foo class], how

  • 0
@interface Foo : NSObject {
}

- (Bar)bar;

At runtime, given [Foo class], how do we find out the return type of all methods Foo has?

I have been studying the Objective-C runtime API for a while now; as far as I could tell, there is no way to get the return type (i.e. Class) of a method or a property. This seems to be a serious omission in any reflection API.

  • 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-25T16:01:29+00:00Added an answer on May 25, 2026 at 4:01 pm

    You can tell basic information like what C type it is, but you can’t differentiate between various instance types (or classes) on the return type.

    Objective-C was never designed nor intended to have that level of a reflection. Mostly because doing so would massively increase the size of the executables (all the metadata) and supporting full argument/return-type metadata introspection for all C types — think C++ types — would be incredibly complex.

    Already, there have been cases where the metadata related to the parameterization of methods has measured in the orders of magnitude larger than the generated code when passing C++ objects to Objective-C methods (literally — MBs for the metadata for a single method call).


    An example of a relatively simple type in argument/return-type metadata form:

    {CGRect={CGPoint=dd}{CGSize=dd}}96@0:8@16{CGRect={CGPoint=dd}{CGSize=dd}}24{CGRect={CGPoint=dd}{CGSize=dd}}56q88
    

    And a particularly egregious example from the WebKit:

    ^{Document=^^?^^?i^{ContainerNode}{Weak=^{JSValue}}^{Document}^{Node}^{Node}^{RenderObject}I^{Node}^{Node}^{TreeScope}{DocumentOrderedMap={HashMap,WTF::HashTraits,WTF::HashTraits

    ={HashTable,WTF::PairFirstExtractor
    ,WTF::PtrHash,WTF::PairHashTraits,
    WTF::HashTraits
    ,WTF::HashTraits
    =^{pair}iiii}}{HashCountedSet,WTF::HashTraits
    ={HashMap,WTF::HashTraits,WTF::HashTraits
    ={HashTable,WTF::PairFirstExtractor
    ,WTF::PtrHash,WTF::PairHashTraits,
    WTF::HashTraits
    ,WTF::HashTraits
    =^{pair}iiii}}}}{DocumentOrderedMap={HashMap,WTF::HashTraits,WTF::HashTraits
    ={HashTable,WTF::PairFirstExtractor
    ,WTF::PtrHash,WTF::PairHashTraits,
    WTF::HashTraits
    ,WTF::HashTraits
    =^{pair}iiii}}{HashCountedSet,WTF::HashTraits
    ={HashMap,WTF::HashTraits,WTF::HashTraits
    ={HashTable,WTF::PairFirstExtractor
    ,WTF::PtrHash,WTF::PairHashTraits,
    WTF::HashTraits
    ,WTF::HashTraits
    =^{pair}iiii}}}}I^^?{RefPtr=^{SecurityOrigin}}{HashSet,WTF::HashTraits
    ={HashTable,WTF::PtrHash,WTF::HashTraits,WTF::HashTraits
    =^^{MessagePort}iiii}}{HashMap,WTF::HashTraits,WTF::HashTraits
    ={HashTable,WTF::PairFirstExtractor
    ,WTF::PtrHash,WTF::PairHashTraits,
    WTF::HashTraits >,WTF::HashTraits
    =^{pair}iiii}}BB{HashMap,WTF::HashTraits,WTF::HashTraits
    ={HashTable,WTF::PairFirstExtractor >,WTF::IntHash,WTF::PairHashTraits,
    WTF::HashTraits >,WTF::HashTraits
    =^{pair}iiii}}B{OwnPtr,
    0ul>
    =^{Vector,0ul>}}{RefPtr=^{DatabaseThread}}Bi{OwnPtr=^{CSSStyleSelector}}BB{RefPtr=^{CSSPrimitiveValueCache}}^{Frame}{OwnPtr=^{CachedResourceLoader}}{RefPtr=^{DocumentParser}}B{KURL={String={RefPtr=^{StringImpl}}}b1b1iiiiiiiiii}{KURL={String={RefPtr=^{StringImpl}}}b1b1iiiiiiiiii}{KURL={String={RefPtr=^{StringImpl}}}b1b1iiiiiiiiii}{KURL={String={RefPtr=^{StringImpl}}}b1b1iiiiiiiiii}{KURL={String={RefPtr=^{StringImpl}}}b1b1iiiiiiiiii}{String={RefPtr=^{StringImpl}}}{String={RefPtr=^{StringImpl}}}{RefPtr=^{DocumentType}}{OwnPtr=^{DOMImplementation}}iBiB{RefPtr=^{CSSStyleSheet}}{RefPtr=^{CSSStyleSheet}}{RefPtr=^{CSSStyleSheet}}{OwnPtr,
    0ul>
    =^{Vector,0ul>}}BBBBiB{Color=IB}{RefPtr=^{Node}}{RefPtr=^{Node}}{RefPtr=^{Node}}{RefPtr=^{Element}}Q{HashSet,WTF::HashTraits
    ={HashTable,WTF::PtrHash,WTF::HashTraits,WTF::HashTraits
    =^^{NodeIterator}iiii}}{HashSet,WTF::HashTraits
    ={HashTable,WTF::PtrHash,WTF::HashTraits,WTF::HashTraits
    =^^{Range}iiii}}S{RefPtr=^{StyleSheetList}}{ListHashSet
    ={HashTable,WTF::ListHashSetNode,WTF::IdentityExtractor*>,WTF::ListHashSetNodeHashFunctions
    ,WTF::HashTraits*>,WTF::HashTraits*>
    =^^{ListHashSetNode}iiii}^{ListHashSetNode}^{ListHashSetNode}{OwnPtr
    =^{ListHashSetNodeAllocator}}}{ListHashSet
    ={HashTable,WTF::ListHashSetNode,WTF::IdentityExtractor*>,WTF::ListHashSetNodeHashFunctions
    ,WTF::HashTraits*>,WTF::HashTraits*>
    =^^{ListHashSetNode}iiii}^{ListHashSetNode}^{ListHashSetNode}{OwnPtr
    =^{ListHashSetNodeAllocator}}}{ListHashSet
    ={HashTable,WTF::ListHashSetNode,WTF::IdentityExtractor*>,WTF::ListHashSetNodeHashFunctions
    ,WTF::HashTraits*>,WTF::HashTraits*>
    =^^{ListHashSetNode}iiii}^{ListHashSetNode}^{ListHashSetNode}{OwnPtr
    =^{ListHashSetNodeAllocator}}}{HashMap,WebCore::FormElementKeyHash,WebCore::FormElementKeyHashTraits,WTF::HashTraits >
    ={HashTable
    ,WTF::PairFirstExtractor >
    ,WebCore::FormElementKeyHash,WTF::PairHashTraits >
    ,WebCore::FormElementKeyHashTraits>=^{pair
    }iiii}}{Color=IB}{Color=IB}{Color=IB}{String={RefPtr=^{StringImpl}}}{String={RefPtr=^{StringImpl}}}BBiB{Timer=^^?ddiI^{Document}{?=^q}}BBBBBBBBBBBBBBBBBI{StringWithDirection={String={RefPtr=^{StringImpl}}}i}{StringWithDirection={String={RefPtr=^{StringImpl}}}i}B{RefPtr=^{Element}}{OwnPtr=^{RenderArena}}^{AXObjectCache}{OwnPtr=^{DocumentMarkerController}}{Timer=^^?ddiI^{Document}{?=^q}}^{Element}B{RefPtr=^{SerializedScriptValue}}dBi{OwnPtr=^{ScriptRunner}}{OwnPtr=^{TransformSource}}{RefPtr=^{Document}}i{String={RefPtr=^{StringImpl}}}{String={RefPtr=^{StringImpl}}}B{String={RefPtr=^{StringImpl}}}^{RenderObject}{RefPtr=^{TextResourceDecoder}}i{CheckedRadioButtons={OwnPtr,
    WTF::HashTraits,
    WTF::HashTraits >
    =^{HashMap,WTF::HashTraits,WTF::HashTraits
    }}}{FixedArray=[10{CollectionCache=Q^{Element}IIi{HashMap,WTF::PtrHash,WTF::HashTraits,WTF::HashTraits*>
    ={HashTable,std::pair*>,WTF::PairFirstExtractor*>
    ,WTF::PtrHash,WTF::PairHashTraits,
    WTF::HashTraits*>
    ,WTF::HashTraits
    =^{pair*>}iiii}}{HashMap,WTF::PtrHash,WTF::HashTraits,WTF::HashTraits*>
    ={HashTable,std::pair*>,WTF::PairFirstExtractor*>
    ,WTF::PtrHash,WTF::PairHashTraits,
    WTF::HashTraits*>
    ,WTF::HashTraits
    =^{pair*>}iiii}}BB}]}{FixedArray,
    WTF::HashTraits,
    WTF::HashTraits
    ,2ul>=[2{HashMap,WTF::HashTraits,WTF::HashTraits
    ={HashTable,WTF::PairFirstExtractor
    ,WTF::PtrHash,WTF::PairHashTraits,
    WTF::HashTraits
    ,WTF::HashTraits
    =^{pair}iiii}}]}{RefPtr=^{XPathEvaluator}}{OwnPtr=^{SVGDocumentExtensions}}{Vector=Q{VectorBuffer=^{DashboardRegionValue}Q}}BB{HashMap,WTF::StringHash,WTF::HashTraits,WTF::HashTraits

    ={HashTable
    ,WTF::PairFirstExtractor >
    ,WTF::StringHash,WTF::PairHashTraits,
    WTF::HashTraits >
    ,WTF::HashTraits
    =^{pair
    }iiii}}BB[1{IconURL=i{KURL={String={RefPtr=^{StringImpl}}}b1b1iiiiiiiiii}}]{HashSet,WTF::HashTraits
    ={HashTable,WTF::PtrHash,WTF::HashTraits,WTF::HashTraits
    =^^{Element}iiii}}{HashSet,WTF::HashTraits
    ={HashTable,WTF::PtrHash,WTF::HashTraits,WTF::HashTraits
    =^^{Element}iiii}}{HashSet,WTF::HashTraits
    ={HashTable,WTF::PtrHash,WTF::HashTraits,WTF::HashTraits
    =^^{Element}iiii}}{HashMap,WTF::HashTraits
    ={HashTable,WTF::PairFirstExtractor
    ,WTF::CaseFoldingHash,WTF::PairHashTraits,
    WTF::HashTraits >,WTF::HashTraits
    =^{pair}iiii}}BBBBBBB{RefPtr=^{EventQueue}}{RefPtr=^{DocumentWeakReference}}{HashSet,WTF::HashTraits
    ={HashTable,WTF::PtrHash,WTF::HashTraits,WTF::HashTraits
    =^^{MediaCanStartListener}iiii}}{QualifiedName=^{QualifiedNameImpl}}B{RefPtr=^{Element}}^{RenderFullScreen}{Timer=^^?ddiI^{Document}{?=^q}}{Deque,0ul>=QQ{VectorBuffer,0ul>=^{RefPtr}Q}}B{IntRect={IntPoint=ii}{IntSize=ii}}{RefPtr=^{RenderStyle}}i{Timer=^^?ddiI^{Document}{?=^q}}{ViewportArguments=fffffff}BB{DocumentTiming=ddddd}{RefPtr=^{MediaQueryMatcher}}BII{RefPtr=^{ContentSecurityPolicy}}}16@0:8

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

Sidebar

Related Questions

Assume that I have this piece of code: @interface Foo : NSObject { Bar
Suppose we have: interface Foo { bool Func(int x); } class Bar: Foo {
So I have a custom class Foo that has a number of members: @interface
interface Foo<T> { ... } class Bar implements Foo<Baz> { ... } I've got
If we have: public interface Foo{} public class Bar implements Foo{...} Is there a
interface Foo<T extends Number>{ } class Bar<T extends Number> implements Foo<T>{ } Why does
Say I have the following Objective-C class: @interface Foo { int someNumber; NSString *someString;
Given the following interfaces: interface IFoo { void Foo(); } interface IBar : IFoo
What is the difference between: type IFooable = interface IDisposable abstract Foo : (unit
Have a interface class abc { public: virtual int foo() = 0; ... }

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.