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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:20:27+00:00 2026-06-17T18:20:27+00:00

I am using performSelector: , which returns an id object, to call several other

  • 0

I am using performSelector:, which returns an id object, to call several other methods. The return type of those methods can actually be either be a BOOL, int, NSDate or any other kind of object.

How can I figure out whether the object returned from performSelector: is a BOOL or not?
I tried converting it to a NSNumber and such, but this crashes if the object is not a BOOL.

I have a class with attributes such as these:

@property(retain,nonatomic) NSString* A;
@property(assign,nonatomic) BOOL B;
@property(retain,nonatomic) NSArray* C;
@property(assign,nonatomic) int64_t D;

This class is generated by a framework, so I cannot change it. But I want to loop over A, B, C, D to call each attribute and retrieve the data. However, as you can see, the return type can vary and I need to adjust to that.

I am doing something similar to:

SEL s = NSSelectorFromString(@"A");
id obj = [object performSelector:s];
//check if obj is BOOL
//do something with obj
  • 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-17T18:20:28+00:00Added an answer on June 17, 2026 at 6:20 pm

    If all you need to do is obtain the values of various properties, use key-value coding, which automatically wraps scalar types such as int and BOOL in instances of NSNumber. So all you would need would be a line like the following:

    id value = [object valueForKey:@"somePropertyName"];
    

    Otherwise, you could check ahead of time for the return type by calling methodSignatureForSelector: on the target object, but that seems like a bunch of unnecessary work given the situation you described.

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

Sidebar

Related Questions

If I'm using ARC, how can I call the following method using performSelector: without
Possible Duplicate: Using -performSelector: vs. just calling the method I can accomplish the same
I am using performSelector to call URLRequest every couple of second with different timetstamp.
Using a populated Table Type as the source for a TSQL-Merge. I want to
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question
Using Location.getBearing(); I seem to get randomly changing bearings. Aka, I can turn the
Using ASIHTTPRequest, I downloaded a zip file containing a folder with several audio files.
I am developing an application, in which one of the screen i am using
My problem is, at some point in my application I call [performSelector: withObject: afterDelay:]
Is there a way to do multiple actions respectively using the : performSelector:withObject:afterDelay code

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.