Welcome, Guest. Please login or register.
Did you miss your activation email?
July 30, 2016, 03:39:15 PM
Home Help Search chat Login Register 
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan

+ Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+ Old Stuff
| |-+ Answers to Exercises
| | |-+ Chapter 16 (Moderator: sgg_admin)
| | | |-+ Question about exercise 16-4. Do it dinamically?
Pages: [1] Go Down
Author Topic: Question about exercise 16-4. Do it dinamically? (Read 1430 times)
Posts: 1

on: February 11, 2009, 06:19:15 AM


On the 16-4 exercise we are asked to display all the information returned by NSProcessInfo getter methods.

Is there a way to do that in a loop?
I mean, if I had a list of all the selectors, I could just invoke the methods using performSelector: and NSLog the result.

I searched for a way to get all the selectors available on a NSObject but couldn't find it.

Thanks in advance!
Hero Member
Posts: 3114

Reply #1 on: February 11, 2009, 06:57:33 AM

Although I've never done it, I imagine you can get access to a class' dispatch table (identified by the object's isa variable) and run through and invoke the methods in that table.  The inherited methods are stored in the superclass' dispatch table, so you'd have to address that.  You'd also have to know the arguments and return type of each method, and the ability to distinguish class from instance methods and setters from getters. 

This is advanced stuff well beyond the scope of this book!    Smiley


Pages: [1] Go Up
Jump to:

Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.