title: Objective-C Scripting Bridge and Apple Remote Desktop
body: <p>Trying to automatically view a computer in Apple Remote Desktop via Scripting Bridge in Objective-C with this:</p>
  
  <pre><code>
      @try {
          SBApplication *RD = [SBApplication applicationWithBundleIdentifier:@"com.apple.RemoteDesktop"];
  
          // (code to check for ARD running and installed omitted here)
          [RD activate]; // works just fine
  
          RemoteDesktopComputer *computer = [[[RD classForScriptingClass:@"computer"] alloc]     initWithProperties:
              [NSDictionary dictionaryWithObjectsAndKeys:
                  ipAddress,@"InternetAddress", // looked up from header
                  nil
               ]
          ];
  
          // attempt to add it to a container first:
          [(SBElementArray*)[(RemoteDesktopApplication*)RD computers] addObject:computer]; 
          // this is what raises the exception:
          [computer observeZooming:Nil];
      }
      @catch (NSException *e) {
          NSLog(@"Exception: %@", [e description]);
      }
  </code></pre>
  
  <p>Running this yields the following exception in the log:</p>
  
  <pre><code>    Exception: *** -[SBProxyByClass observeZooming:]: object has not been added to a container yet; selector not recognized [self = 0x6050004819b3]
  </code></pre>
  
  <p>I've done as much research as there is available on this subject and have learned that SB isn't the easiest to deal with because of how it's wired under the hood, but any experts or veterans of native Scripting Bridge (no third party frameworks or languages other than obj-c, please) is much appreciated. </p>
  
  <p>All prerequisites like linking to the ScriptingBridge.framework and importing Remote Desktop.h are performed - the typecasts are to avoid what appear to be unavoidable link-time errors when building...</p>
  
  <p><strong>Edit 1:</strong> Reading the documentation on SBObject (parent of RemoteDesktopComputer) says that it's a reference rather than an actual instance, which you can fetch by calling SBObject's get method (returns id). So I tried running this as well but unfortunately received the same results:</p>
  
  <pre><code>    [[computer get] observeZooming:Nil];</code></pre>
  
  <p>Here's the documentation on SBObject: <a href="https://developer.apple.com/library/mac/documentation/cocoa/Reference/SBObject_Class/SBObject/SBObject.html#//apple_ref/occ/instm/SBObject/get" rel="nofollow">https://developer.apple.com/library/mac/documentation/cocoa/Reference/SBObject_Class/SBObject/SBObject.html#//apple_ref/occ/instm/SBObject/get</a></p>
  
  <p>Still trying...</p>