delegates

Handler invocation speed: Objective-C vs virtual functions

I heard that calling a handler (delegate, etc.) in Objective-C can be even faster than calling a virtual function in C++. Is it really correct? If so, how can that be? AFAIK, virtual functions are not that slow to call. At least, this is my understanding of what happens when a virtual function is called: Obtain the pointer to vtbl. De...

Delegates in .NET: how are they constructed ?

While inspecting delegates in C# and .NET in general, I noticed some interesting facts: Creating a delegate in C# creates a class derived from MulticastDelegate with a constructor: .method public hidebysig specialname rtspecialname instance void .ctor(object 'object', native int 'method') runtime managed { } Meaning that it exp...

Reusing Linq to Entities' Expression<Func<T, TResult> in Select and Where calls

Hi, Suppose I have an entity object defined as public partial class Article { public Id { get; set; } public Text { get; set; } public UserId { get; set; } } Based on some properties of an Article, I need to determine if the article can be ...

Performance of delegate and method group

Hi I was investigating the performance hit of creating Cachedependency objects, so I wrote a very simple test program as follows: using System; using System.Collections.Generic; using System.Diagnostics; using System.Web.Caching; namespace Test { internal class Program { private static readonly string[] keys = new[] {"A...

- (void)alertViewCancel:(UIAlertView *)alertView is not called

Hi all I've got the problem that the UIAlertViewDelegate method - (void)alertViewCancel:(UIAlertView *)alertView is not called when I cancel a AlertView with it's cancel button. Weird is that the delegate method - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex works perfectly. Does anyone have an ...

XML comments on delegate declared events

I am visiting some old code, and there are quite a few events declared with delegates manually rather than using EventHandler<T>, like this: /// <summary> /// Delegate for event Added /// </summary> /// <param name="index">Index of the item</param> /// <param name="item">The item itself</param> public delegate void ItemAdded(int index, ...

how to set a tableview delegate

Hi, I'm trying to use a tableview without using a nib and without using a UITableViewController. I have added a UITableView instance to a UIViewController Like So mytable = [[UITableView alloc] initWithFrame:CGRectMake(22, 207, 270, 233)]; [mytable setDelegate:self]; [self.view mytable]; Also I have added the following table view me...

how do i know when to use a datasource or delegate protocol when using a UI object in my project?

for example the UIPickerView, in the tutorial that i am learning i had to include the datasource and delegate protocols in my project for the pickerview to work. how would i know on other objects? ...

In .NET, what thread will Events be handled in?

I have attempted to implement a producer/consumer pattern in c#. I have a consumer thread that monitors a shared queue, and a producer thread that places items onto the shared queue. The producer thread is subscribed to receive data...that is, it has an event handler, and just sits around and waits for an OnData event to fire (the data...

Func delegate with ref variable

public object MethodName(ref float y) { //method } How do I defined a Func delegate for this method? ...

Cocoa: NSApp beginSheet sets the application delegate?

I am trying to display a custom sheet in my application, but I think I am doing something wrong. While everything seems to be working just fine, I have a rather odd side-effect. (which took hours to figure out). It turns out that everytime I display a sheet in my application, the Application delegate gets set to the instance of the sheet...

Understanding AddHandler and pass delegates and events.

I am using AddHandler to wire a function to a control's event that I dynamically create: Public Delegate Sub MyEventHandlerDelegate(ByVal sender As Object, ByVal e As System.EventArgs) Public Sub BuildControl(EventHandler as System.Delegate) dim objMyButton as new button AddHandler objMyButton.Click, EventHandler ...

Please Explain .NET Delegates

So I read MSDN and Stack Overflow. I understand what the Action Delegate does in general but it is not clicking no matter how many examples I do. In general, the same goes for the idea of delegates. So here is my question. When you have a function like this: public GetCustomers(Action<IEnumerable<Customer>,Exception> callBack) { } Wh...

Instantiating a System.Threading.Thread object in Jscript

I'm trying to create a new System.Threading.Thread object using Jscript, but I can't get the constructor to work. If I just do the following, var thread = new Thread( threadFunc ); function threadFunc() { // do stuff } then I get error JS1184: More than one constructor matches this argument list. However, if I try to coerce thr...

How to handle multiple delegates

I've got a view in my app that does pretty much everything, and I like it that way. The problem however is that it's implementing 5 or 6 different delegates, which seems a little bit messy. My question is, does the view controller have to implement all of the delegates? or is there some way I can separate the code out into different fil...

UITableView - listen to bounce?

Hallo all. Ist there a way to listen to the event when a UITableView bounces back? I want to be notified, when the User releases the Table and it scrolls back to the top, i.e. he/she dragged it down so far, that one can see the background behind the table. Is there a good way to 'listen' to this and be notified? E.g. via a listener, de...

How do I fix 'compiler error - cannot convert from method group to System.Delegate'?

public MainWindow() { CommandManager.AddExecutedHandler(this, ExecuteHandler); } void ExecuteHandler(object sender, ExecutedRoutedEventArgs e) { } Error 1 Argument 2: cannot convert from 'method group' to 'System.Delegate' ...

Core Location Best Placement and User Interruption

Hi All, My application uses Core Location in three different views. It's working perfectly. In my first view, I subclass the CLLocationManager and use protocol methods for location updates to my calling class. Before I install the framework and code in my other classes, I was wondering: Is the protocol method the best way? What happ...

What's the proper way to setup different objects as delegates using Interface Builder?

Let's say I create a new project. I now add two text fields to the view controller in Interface Builder. I want to respond to delegate events that the text fields create, however, I don't want to have the main view controller to act as the delegate for both text fields. Ideally I want a separate file for each text field that acts as the ...

Why is there no * in front of delegate declaration ?

Hey guys, I just noticed there is no * in front of the declaration for a delegate ... I did something like this : @protocol NavBarHiddenDelegate; @interface AsyncImageView : UIView { NSURLConnection* connection; NSMutableData* data; UIActivityIndicatorView *indicator; id <NavBarHiddenDelegate> delegate; } @prope...