Amazon.com Widgets Class versus Instance methods in Program 9.3
Welcome, Guest. Please login or register.
Did you miss your activation email?
June 17, 2013, 11:38:44 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
|-+  Programming in Objective-C, 4th edition
| |-+  Chapter 9
| | |-+  Class versus Instance methods in Program 9.3
Pages: [1]   Go Down
Print
Author Topic: Class versus Instance methods in Program 9.3  (Read 463 times)
StanleyRShapiro
Newbie
*
Posts: 6


Email




« on: June 10, 2012, 11:33:14 PM »

Can someone explain how the particular line of code works:

if([Square respondsToSelector: @selector (alloc)] == YES)
...

My confusion is that respondsToSelector: is an instance method (-(BOOL) repondsToSelector:), yet the receiver of the message is the CLASS Square.
Logged
afterDark
Global Moderator
Full Member
*****
Posts: 126






« Reply #1 on: November 21, 2012, 01:43:43 PM »

In the documentation, which seems endless and huge, I could find that NSProxy has a class method +(BOOL)respondsToSelector:

but NSObject only has
-(BOOL)respondsToSelector:

Of course, I can and probably have missed something in the documentation. But for now I also do not understand why subclasses of NSObject can use this method.

edit:
I now found Steve's view on this:
http://classroomm.com/objective-c/index.php?topic=6887.msg18791#msg18791
It seems it is not really well known how it works exactly.
« Last Edit: November 21, 2012, 01:47:12 PM by afterDark » Logged

I am just an amateur with Objective-C, don't let the moderator label fool you. Working my way through the book slowly.
Pages: [1]   Go Up
Print
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.