Reviewing Concepts: Our Kind of Portal?
This GDB was configured as "x86_64-apple-darwin".tty /dev/ttys000
Loading program into debugger…
Program loaded.
run
[Switching to process 28127]
Running…
 The SLO Portal is a TimePortal
Debugger stopped.
Program exited with status value:0.
#import <stdio.h>
#import <Foundation/NSObject.h>
//  
// Based on ideas from Page 116 of Virtual Quickstart Guide Objective-C (Holzner)
// Verify that an object belongs to a class
// TIME TRAVEL IMPLEMENTATION
//    Verify that an object is a Time Travel Portal
//     Note: Travellers are into Slow Travel these days and Period Pilots likes to stay abreast of trends
//            so portals in SLO are particularly interesting
// It looks like 'isKindOfClass is a METHOD inherited from the NSObject superclass/baseclass
// isKindOfClass tells me wether an object is
//     a) a member of a class (like isMemberOfClass does)
// AND b) is a a member of any class derivedfrom that class
//
@interface TimePortal:NSObject
-(void) print;
@end
//METHODS  for TimePortal
@implementation TimePortal
-(void) print
{
    printf("This is TimePortal.\n");
}
@end
@interface SLOPortal:TimePortal
-(void) print;
@end
//METHODS  for SLOPortal
@implementation SLOPortal
-(void) print
{
    printf("This is SLOPortal.\n");
}
@end
int main (void) {
    TimePortal *c1 = [TimePortal new];
    
    // Find syntax for this method
    //
    
    if ([c1 isKindOfClass: [TimePortal class]]  ==YES)
    {
        printf("The SLO Portal is a TimePortal\n");
    }
    
     return 0;
}
 
 
 
          
      
 
  
 
 
 
 
 
 
 
 
 
 
No comments:
Post a Comment