• 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: running an external app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: running an external app


  • Subject: Re: running an external app
  • From: Johnny Lundy <email@hidden>
  • Date: Mon, 26 May 2008 23:29:28 -0400

True the OP needs to learn Objective-C. But let me just throw in here one of my infamous objections to the documentation, namely the Class Reference sections.

Here is the Class Reference documentation on NSWorkspace's launchApplication: method:


launchApplication:
Launches the specified application.

- (BOOL)launchApplication:(NSString *)appName

Parameters

appName
The name of the application to open.

Return Value
YES if the application was successfully launched or was already running; otherwise, NO.



Now the line
- (BOOL)launchApplication:(NSString *)appName

May be technically the declaration of the method, but is that really useful to anybody? After all, you do not declare this method in your code; you just invoke it. I can't tell you how many times I have been led astray by this terminology - took me at least a year to figure out that the way it is written has nothing to do with how you use it.


The way you would use it is something like

(BOOL) loadedIB = [[NSWorkspace sharedWorkSpace] launchApplication: @"Interface Builder"];

Which bears no resemblance to the line that is written in the documentation.

This OP is NEVER going to figure that out from the line in the documentation. Even the "discussion" goes on and on about .app extensions and what notifications the method sends, but never mentions how to invoke the thing.

This is why they need to put at least one line in every one of these method documentations to show how it is invoked.

I expect replies to the effect of "it would bloat the documentation", etc., but the fact is, that single example could clarify 1) That you have to message the sharedWorkspace instance, and 2) That you don't actually code "- (BOOL)launchApplication:(NSString *)appName".

With the huge influx of new Cocoa programmers we are about to see, Apple might give some thought to whipping up some example lines to put in these "Class References." Every other reference manual I have ever seen gives the metalanguage and also an example line.

That this OP's basically trying to copy the Reference text in his code shows me that this confusion is very common.

<_< I still have the problem of invalid receiver type bool. The
program compiled but pressing the button did nothing. Please note that
the color of the word "bool" is not pink like it should be.


bool runApp;

whereas:

float firstNumber;

is pink.

I'm also having another problem.... how do I append a single digit to
an int like a calculator does? Again, I checked the documentation and
online but no luck. Am I missing some secret to searching the
documentation? Thanks!

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: running an external app
      • From: Andy Lee <email@hidden>
    • Re: running an external app
      • From: Adam Leonard <email@hidden>
    • Re: running an external app
      • From: Wayne Packard <email@hidden>
    • Re: running an external app
      • From: Ken Thomases <email@hidden>
    • Re: running an external app
      • From: Roland King <email@hidden>
    • Re: running an external app
      • From: Greg Titus <email@hidden>
    • Re: running an external app
      • From: Graham Cox <email@hidden>
  • Prev by Date: Drawing barcodes
  • Next by Date: Re: File's Owner
  • Previous by thread: Re: running an external app
  • Next by thread: Re: running an external app
  • Index(es):
    • Date
    • Thread