home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Examples / Foundation / ForwardInvocation / ForwardInvocation_main.m next >
Text File  |  1996-04-17  |  1KB  |  44 lines

  1. /*
  2.  * You may freely copy, distribute and reuse the code in this example.
  3.  * NeXT Software, Inc. disclaims any warranty of any kind, expressed or implied,
  4.  * as to its fitness for any particular use.  This disclaimer applies to all
  5.  * source files in this example.
  6.  */
  7.  
  8.  
  9. #import <Foundation/Foundation.h>
  10. #import "TargetProxy.h"
  11.  
  12. void doThings(NSMutableString *someThing, NSMutableString *anotherThing) {
  13.     NSRange r1, r2;
  14.  
  15.     if (![[someThing description] isEqual:[anotherThing description]])
  16.         NSLog(@"descriptions not equal!");
  17.     [someThing appendString:@"something else"];
  18.         // will appear to have happened to anotherThing
  19.     if (![[someThing description] isEqual:[anotherThing description]])
  20.         NSLog(@"descriptions after appending not equal!");
  21.     r1 = [someThing rangeOfString:@"some"];
  22.     r2 = [anotherThing rangeOfString:@"some"];
  23.     if (r1.location != r2.location)
  24.         NSLog(@"locations not equal");
  25.     if (r1.length != r2.length)
  26.         NSLog(@"lengths not equal");
  27. }
  28.  
  29. int main (int argc, const char *argv[])
  30. {
  31.    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
  32.  
  33.    NSMutableString *funny = [[@"and now for " mutableCopy] autorelease];
  34.    TargetProxy *tp = [TargetProxy proxyWithTarget:funny];
  35.  
  36.    doThings(funny, (NSMutableString *)tp);
  37.  
  38.    NSLog(@"done!");
  39.  
  40.    [pool release];
  41.    exit(0);       // insure the process exit status is 0
  42.    return 0;      // ...and make main fit the ANSI spec.
  43. }
  44.