• 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: Ken Thomases <email@hidden>
  • Date: Mon, 26 May 2008 23:10:12 -0500

On May 26, 2008, at 10:29 PM, Johnny Lundy wrote:

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

May be technically the declaration of the method, but is that really useful to anybody?

Yes, absolutely. It's useful to thousands of Cocoa programmers every day.


It is absurd to think somebody is going to attempt to program Objective-C without understanding a declaration and how it translates into a message expression. Once again, every field of study requires that you familiarize yourself with the basics in order to understand it.

If you're going to refuse to learn Objective-C before you learn a framework that depends on it, you might as well just stop now. (Note, OP has not expressed any such refusal. He just seems to have jumped the gun a bit, which is fine.)

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.

Wow. Words fail.



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.

Even if I were to grant that it bears no resemblance, so what? Why would you expect it to? It's for informing you about the method, which it does quite thoroughly.


Do you simply not want to think about what you're doing and what things mean, but just want snippets of code so you can assemble your programs entirely through cut-paste-and-tweak? I'm afraid that won't get you very far.

Frankly, how could you not understand the difference between a method declaration and a message invocation and yet written any original code? Surely, you would had to have written your own methods, with their declarations, and also written message invocations of those methods. Right?


This OP is NEVER going to figure that out from the line in the documentation.

This OP won't -- unless he learns how to program in Objective-C. Quelle surprise! Same applies to everybody else, including all of the extent and proficient Cocoa programmers out there. Plenty of people can figure it out from that documentation, and have, but they had to learn Objective-C first.


I remind you once again that Objective-C is the language, which is distinct from Cocoa the framework. So, the same difficulty would face anybody writing anything in Objective-C without bringing any aspect of Cocoa or its documentation into the question. That's part of the reason that lessons in programming Objective-C don't belong in documentation that's about the framework.


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.

Nobody who can't figure that out has any business reading the framework documentation. It's a classic case of putting the cart before the horse.


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".

Did you read the Overview section of the NSWorkspace class reference? It doesn't happen to exercise the launchApplication: method, but it shows a perfectly sensible example of using NSWorkspace.



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

Actually, it doesn't show that at all. It shows that you and OP have that difficulty. I'm sure there are a few others, but they're very rare on this list, in my experience.



This analogy has been provided to you before, apparently with little impact, but I'll try again: when a cookbook describes a recipe, does it have to include instructions about how to cut vegetables, or how to boil water, or how to operate your stove, or whatever, with every recipe? No. To the extent that such instruction is necessary, it's provided in an introductory chapter of the cookbook and the rest of the book expects the reader to be familiar with those concepts in advance.


Does a calculus textbook reiterate algebra every time it uses it, or does it simply state at the outset that knowledge of algebra is a prerequisite for understanding the concepts of calculus?

-Ken
_______________________________________________

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


References: 
 >Re: running an external app (From: Johnny Lundy <email@hidden>)

  • Prev by Date: Re: running an external app
  • Next by Date: Re: running an external app
  • Previous by thread: Re: running an external app
  • Next by thread: Re: running an external app
  • Index(es):
    • Date
    • Thread