This is Demo2.m in view mode; [Download] [Up]
#import "Demo2.h" #import "UHInspectorManager.h" #import "Clipper.h" #import "Gain.h" #import "Sine.h" #import "Block.h" @implementation Demo2 - init { [super init]; selection=[[List alloc] initCount:3]; //object selection list /* First get the inspector manager, which will load its own nib. */ inspectorManager=[[UHInspectorManager alloc] init]; [inspectorManager setDelegate:self]; [inspectorManager enableDoubleInspector:YES]; [inspectorManager setButtonTitleForObjects:"Principal Objects"]; [inspectorManager setButtonTitleForReferences:"Reference Objects"]; /* Now get the objects to be inspected for this Demo2. Not all inspectable objects must respond to setLabel:, but I know that these do. */ clipper=[[[Clipper alloc] init] setLabel:"clipper"]; gain=[[[Gain alloc] init] setLabel:"gain"]; sine=[[[Sine alloc] init] setLabel:"sine"]; block1=[[[[Block alloc] init] setLabel:"block1"] setReference:clipper]; block2=[[[[Block alloc] init] setLabel:"block2"] setReference:gain]; block3=[[[[Block alloc] init] setLabel:"block3"] setReference:sine]; return self; } - doInspect:sender { switch([sender selectedTag]){ case 0: //an empty list has no inspector [selection empty]; [inspectorManager inspectList:selection requestor:self]; break; case 1: //a block with a clipper reference [inspectorManager inspect:block1 requestor:self]; break; case 2: //a block with a gain reference [inspectorManager inspect:block2 requestor:self]; break; case 3: //a block with a sine reference [inspectorManager inspect:block3 requestor:self]; break; case 4: //two blocks [selection empty]; [selection addObject:block1]; [selection addObject:block2]; [selection addObject:block3]; [inspectorManager inspectList:selection requestor:self]; break; } return self; } /* Message to delegate from UHInspectorManager when inspector is changed in inspector manager. */ - inspectorChanged:sender { sprintf(buf,"Inspector changed to %s.",[[sender currentInspector] name]); [delegateMsgField setStringValue:buf]; return self; } /* Message to requestor from inspector (UHInspector subclass) when a single object is inspected. */ - objectWasInspected:object { if([object respondsTo:@selector(label)]) sprintf(buf,"Object inspected has label %s.",[object label]); else sprintf(buf,"Object inspected has no label."); [requestorMsgField setStringValue:buf]; return self; } /* Message to requestor from inspector (UHInspector subclass) when an object list is inspected. */ - objectListWasInspected:objectList { if([objectList count]==1){ id object=[objectList objectAt:0]; if([object respondsTo:@selector(label)]) sprintf(buf,"Object inspected has label %s.",[object label]); else sprintf(buf,"Object inspected has no label."); [requestorMsgField setStringValue:buf]; } else [requestorMsgField setStringValue:"Multiple objects inspected."]; return self; } - showInspector:sender { [inspectorManager showInspector:self]; return self; } @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.