home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / MiscKit1.7.1 / MiscKit / Examples / IBMole / main1.m < prev    next >
Encoding:
Text File  |  1995-04-12  |  1.7 KB  |  75 lines

  1. // Copyright (C) 1995.  This code is governed by the MiscKit license
  2.  
  3. #import <remote/NXConnection.h>
  4. /*
  5.     This is the nastiest program I've done so far.  In fifteen minutes it changed 800+ SmartFields in 33 nibs into TextFields and SmartCells into TextCells.  If you have ever seriously used SmartFields then you probably know why I wanted to do that.
  6. */
  7.  
  8. main()
  9. {
  10.     id server;
  11.     id docList;
  12.     int count;
  13.     id 
  14.         obj,
  15.         cell,
  16.         parser;
  17.     char
  18.         buf[256]="";
  19.     server = [NXConnection connectToName:"IBMole"];
  20.     if (server)
  21.     {
  22.         printf("Got the mole!\n");
  23.     }
  24.     docList = [server docList];
  25.     count = [docList count];
  26.     printf("%d docs\n",count);
  27.     while (count--)
  28.     {
  29.         int objCount;
  30.         id objs=[[List alloc] init];
  31.         
  32.         [[docList objectAt:count] getObjects:objs];
  33.         objCount = [objs count];
  34.     printf("%d objects\n",objCount);
  35.         while (objCount--)
  36.         {
  37.             cell = nil;
  38.             obj = [objs objectAt:objCount];
  39.             printf("%s class\n",[[obj class] name]);
  40.             if ([obj respondsTo:@selector(setTextDelegate:)])
  41.             {
  42.                 [obj setTextDelegate:NULL];
  43.                 printf("Changed textDelegate\n");
  44.             }
  45.             if (!strcmp("OTSmartField",[[obj class] name]))
  46.             {
  47.                 cell = [obj cell];
  48.             }
  49.             
  50.             if (!strcmp("OTSmartCell",[[obj class] name]))
  51.             {
  52.                 cell = obj;
  53.             }
  54.             printf("cell is %s\n",[[cell class] name]);
  55.             printf("parser is %s\n",[[[cell parser] class] name]);
  56.             if (cell)
  57.             {
  58.                 parser = [cell parser];
  59.                 if (!strcmp("OTPvdLookup",[[parser class] name]))
  60.                 {
  61.                     if ([obj isEditable] && strcmp("date",[parser lookupName]))
  62.                     {//becomeSuperclass method installed as a catagory to Object in my palette...
  63.                         [obj becomeSuperclass];
  64.                         [cell becomeSuperclass];
  65.                         printf("Turned a SmartField to a TextField!\n");
  66.                     }
  67.                     printf(".\n");
  68.                 }
  69.             }
  70.  
  71.         }
  72.     }
  73.     exit(0);
  74. }
  75.