• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: best way to launch an application with an NSArray argument
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: best way to launch an application with an NSArray argument


  • Subject: Re: best way to launch an application with an NSArray argument
  • From: Gore <email@hidden>
  • Date: Fri, 18 Jan 2002 12:53:21 +0200

the best way to open the application is (where appName is a NSString with the name of the app):

[[NSWorkspace sharedWorkspace] launchApplication: appName];


To transmit data to the other application is tricky but you must establish a DO connection between them (DO stands for distributed objects). I have never done this app-to-app thing but I can try explain it (like establishing connection between threads)...(someone else will have to explain this better =) first of all you must launch the app. Then have the other app establish a server-DO connection like this:

// this should be in the instance declaration of the "other" app:

NSConnection *aCon;

// this in the implementation of the "other" app:

- (id)init
{
if (self = [super init]) {
aCon = [NSConnection connectionWithRegisteredName: @"theServer" host: nil];

[aCon setRootObject: self];
}
...
}

- (void)getTheData:(NSArray *)theArray andInt:(int)theInt
{
...
}

// This in the app that will transmitt your data, instance declaration:

id theServerObj;

// This in the app that will transmitt your data, implementation:

- (void)sendTheData:(NSArray *)theArray andInt:(int)theInt
{
if ( ![[NSWorkspace sharedWorkspace] launchApplication: appName] )
return;

theServerObj = [NSConnection rootProxyForConnectionWithRegisteredName: @"theServer" host: nil];

[theServerObj getTheData: theArray andInt: theInt];
}

tell me if this works, I havn't tryed it myself...something I mixed together

On Friday, January 18, 2002, at 11:54 , Angela Brett wrote:

Hi,

This is probably a bit of a newbie question... I want my app to launch another one, passing it an NSArray and an integer. I have tried using environment variables in an NSTask but that doesn't work with the NSArray, it's only happy if I use a string instead. I guess I could post a notification with the information after the app has opened, or write the array to a plist file before opening the other application, or something like that... but that seems kind of kludgy. What is the best way to open an application and send it an array to work with? I don't need to send it any information while it is running, just those two things when it first starts up.
-- Angela Brett email@hidden http://acronyms.co.nz/angela
A mathematician is a machine for turning coffee into theorems -- Paul Erdos
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >best way to launch an application with an NSArray argument (From: Angela Brett <email@hidden>)

  • Prev by Date: Re: Displaying ICON for Device in Finder
  • Next by Date: Re: Newbie Q: How to implement multiple views occupying the same space?
  • Previous by thread: best way to launch an application with an NSArray argument
  • Next by thread: Re: best way to launch an application with an NSArray argument
  • Index(es):
    • Date
    • Thread