| Index | Submit class | Submit snippet | Submission feed | List |

Snippet #57

Language: Objective-C, Author: Michele Balistreri
License: Public domain

This is a sample trampoline application, aiming to simply installation&update of command line tools by Cocoa application. Take a look at http://briksoftware.com/blog/?p=70 for more informations.

int main(int argc, char *argv[]) 
{
  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
  NSWorkspace *env = [NSWorkspace sharedWorkspace];
  NSString *app = [env absolutePathForAppBundleWithIdentifier:@"YOURBUNDLEIDHERE"];
  NSString *targetPath = [[app stringByAppendingPathComponent:@"Contents/Resources/EXECUTABLENAME"] retain];
  
  const char *CStringPath = [targetPath UTF8String];
  [pool release];
  
  execv(CStringPath, argv);
  
  // You reach this code only if execv returns, if execv returns it means that something wrong happened.
  [targetPath release];
  printf("YOURERRORMESSAGE");
  return 0;
}

Compatible with:


Comments

Name

Website

Do you hate spammers? (Answer "Yes")