#import "movie.h"
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
// insert code here...
movie *obj = [[movie alloc]init];
[obj findinterestofnum1:(int)200 num2:(int)4 num3:(int)5];
SEL suf = @selector(findinterestofnum1: num2:num3:);
BOOL sul = [obj respondsToSelector:suf];
if(sul)
{
NSLog(@"It is implememted");
}
else
{
NSLog(@" It is not implemented");
}
NSLog(@"Hello, World!");
[pool drain];
return 0;
}
********-----
@interface movie : NSObject {
@private
}
-(void)findinterestofnum1:(int)p num2:(int)n num3:(int)r;
@end
*******-------
#import "movie.h"
@implementation movie
-(void)findinterestofnum1:(int)p num2:(int)n num3:(int)r
{
int a ;
a= (p*n*r/100);
NSLog(@"interest value is =%d",a);
}
- (void)dealloc
{
[super dealloc];
}
@end
i am trying to find whether method is implemented and if it is not it should print it is no开发者_运维问答t implemented
@toddler, respondsToSelector just checks if the corresponding object can respond to that particular method. It doesn't do any checks on whether interface has that definition associated with it since it is a runtime check.
If you had removed the code from the implementation file (.m file) and not the interface, you would have got an error while executing it and you would have found that the BOOL sul is FALSE.
精彩评论