Solved

What is a delegate exactly

Posted on 2008-10-29
3
12,284 Views
Last Modified: 2013-11-25
I have been 'programming' in Access and VBA for years and outside of High School and College programming classes years ago, that is the extent of my programming.  I am now trying to learn Objective-C to create Iphone apps.  I got a couple great books and found some great tutorial sites, but I have some 'basic' questions that I can not seem to find the answers to anywhere (yeah, this is the same 'into' I used in another question, sorry)

Even in the basic 'Hello World' examples they use SuchAndSuchAppDelegate.  If I remember correctly, one web tutorial says something like 'we are not using the AppDelegate in this project...' What the heck is a delegate and how do you know when to use it or not?

Thanks in advance,

Michael
0
Comment
Question by:UniqueData
3 Comments
 
LVL 3

Accepted Solution

by:
Blackninja2007 earned 250 total points
Comment Utility
In essence, a delegate is a type-safe object that points to another method (or possibly
multiple methods) in the application, which can be invoked at a later time. Specifically speaking,
a delegate type maintains three important pieces of information:

" The name of the method on which it makes calls
" The arguments (if any) of this method
" The return value (if any) of this method

Once a delegate has been created and provided the aforementioned information, it may dynamically
invoke the method(s) it points to at runtime.

0
 
LVL 5

Assisted Solution

by:AJVienna
AJVienna earned 250 total points
Comment Utility
A real world example of a delegate would be:
You have a Person A.
Now you ask Person A to do Task A.
If person A has a delegate for this it would ask its delegate (e.g. Person B) to perform Task A for it.

Delegates are quite useful. Since it often allows to customize the functionality of the class without the need to derive from it. The is especially useful if you only need to customize a very small set of methods. Cocoa uses lots of delegation.

You can also find more information of this in a book regarding Design Patterns or in wikipedia:
http://en.wikipedia.org/wiki/Delegation_pattern
0
 
LVL 7

Author Comment

by:UniqueData
Comment Utility
Thank you much for your posts.  I will chew on this info and read the link.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now