Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

First Responder Explanation Needed

I asked a question earlier on here regarding the use of First Responder - and got a response here:

Trouble with First Responder

Would anyone mind giving me a 'dummies' version of this? Being new to Cocoa, I don't really know where to start with either one of these methods. I award answers quickly

Zach

like image 666
Zakman411 Avatar asked Feb 07 '11 08:02

Zakman411


People also ask

What is the first thing to do as a first responder?

As a first responder, your first step is to assess the situation to ensure the scene is safe. The second step is to assess the victim's airway, breathing, and vascular circulation. If the victim is not breathing, you should have someone else call 911 while you start CPR.

What do you think are the duties of the first responders?

Duties include but are not limited to: ♦ opening and maintaining an airway; ventilating patients; ♦ administering cardiopulmonary resuscitation; ♦ providing emergency medical care of simple and multiple system trauma such as: ♦ controlling hemorrhage, ♦ bandaging wounds, ♦ manually stabilizing injured extremities.

What is the role of the responder?

1. To attend local emergency calls to patients within the defined call out criteria as set by the Trust which may include attending a call to assist the crew on the scene. 2. To provide emergency care for patients until the ambulance arrives.


1 Answers

First Responder is specifically this.

What you're asking about, though, is target-action. You have a UI object (button, menu item) that you need to cause multiple things to happen, but the UI object only sends one action.

Hence the solution: Make that action do multiple things.

Hook the UI object up to an action method you implement in your controller object (in your case, the document). In that method, do all the things the button needs to cause.

The subclassing solution is basically the same thing, except instead of hooking the UI object up to your document, you hook it up to the font manager, but you also make the font manager an instance of a subclass of NSFontManager that you create, rather than an instance of NSFontManager directly. In your subclass, you override addFontTrait: and add the other behavior in your implementation. At either the start or the end of that method, you send [super addFontTrait:sender] to invoke NSFontManager's implementation, so the original implementation gets done.

Long paragraph, but it's not actually all that much more work: The difference is just making the subclass and making the instance an instance of that subclass.


You've said before that “the Apple Documentation is incredibly vague”, but it's really not. There just happens to be a lot of it, and maybe you haven't been looking at the right documents.

These are the documents you need to read, from start to finish, and in order:

EDIT: This list is for Xcode 3. I posted an updated (for Xcode 4) version of this list in another answer.

  1. The Objective-C Programming Language
  2. The Memory Management Programming Guide for Cocoa
  3. The Cocoa Fundamentals Guide (which explains target-action, among other things)
  4. Application Architecture Overview
  5. Resource Programming Guide
  6. Interface Builder User Guide
  7. The Xcode 3 guides:
    1. Xcode Project Management Guide
    2. Xcode Workspace Guide
    3. Xcode Build System Guide
    4. Xcode Debugging Guide
  8. Document-Based Applications Overview

There is also an Instruments User Guide, but, unfortunately, that one is vague—or, to be more precise, incomplete. It omits a lot of useful information, like how to use Instruments' Zombies template to debug crashes. It's a high-level overview, nothing more.

Also, bookmark these:

  • Cocoa Core Competencies, a quick reference to all the concepts you need to use
  • The Foundation Framework Reference
  • The AppKit Framework Reference
  • The Core Foundation Framework Reference
  • The Core Graphics Framework Reference

That's a lot of reading, but it'll tell you everything you need to know, and that order is roughly the order you'll need to know it in.

like image 76
Peter Hosey Avatar answered Oct 16 '22 15:10

Peter Hosey