delegates

Core Animation Callbacks

I'm using core animation to transition between different view states in my application. However, I need to find a way to perform different tasks after the animations finish. I understand I can implement a delegate method and use the - (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag; callback, however there's no ...

How to corectly implement - (NSIndexPath *)indexPathForSelectedRow when tryng to retrieve which table cell is selected

I have a delegate for my table view, and would like to be able to trigger an action when the user selects a cell in the tableview. How is the method - (NSIndexPath *)indexPathForSelectedRow correctly implemented? Thanks in advance. ...

Strange decompiled code from event subscribe code in a generic class

This simple class public class Test<T> { public static void A(Window wa, Window wb) { wa.Closed += (s, e) => wb.Close(); } } Gets compiled to this (I'm using Reflector to decompile) : public class Test<T> { [CompilerGenerated] private sealed class <>c__DisplayClass1 { public Window wb; ...

Invoke a delegate on the main thread in a tiered architecture

I have a background process that i want to regularly maintain the state of gps location. I am not clear on how to invoke a delegate on the main thread in the ui layer when the threaded method is in another class. Here is sample code. My form launches the thread on load: public partial class MainScreen : Form { . . // form st...

how to use a delegate to get by name a CompiledQuery

I'm trying to find and run a CompiledQuery given the name. How do I access the compiled query by name and how do I then invoke the delegate? Here's as far as I can get - I get the error 'Error binding to target method' public class ActivityRepository { private readonly ActivityDataContext _db; public ActivityRepository() {...

Custom field editor for NSTextFieldCell in an NSTableView

I have a custom NSTableView subclass filled with several custom NSTextFieldCell subclasses. I would like to be able to change the edited cell by using the arrow keys. I am able to accomplish this by creating a custom field editor (by subclassing NSTextView) and returning it from the window delegate like so: - (id) windowWillReturnField...

Using selectors for callbacks?

hi, I think i should be using selectors (or even a different paradigm), but even after R'ing TFM I can't figure out what i'm supposed to do. It's all related to callbacks from a delegate I have my main Model object: @implementation Model @synthesize myConnection; // which is an NSURLConnection ... -(void)someMethod{ ...

How would I generalise this C# code into a more general method?

I have numerous occurrences of the following in my code: this.webBrowserCtrl.DocumentCompleted -= new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(this.LoginScreenLoaded); this.webBrowserCtrl.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(this.AttemptLoginAnalysis); I wish to remo...

GridView delegate question in ASP.Net

Let's say I have a GridViewEx class declared which extends GridView. And inside that class, I have a delegate declared called GetDataPage. So it look like this: public class GridViewEx : GridView { public delegate object GetDataPageDelegate(int pageIndex, int pageSize, string sortExpression, IList<FilterItem> filterItems); ...

NSFetchedResultsControllerDelegate methods not being called if its predicate use IN ??

Problem: I'm implementing an UITableViewController in conjunction with NSFetchedResultsController. When the UITableViewController is instantiated the NSFetchedResultsController is constructed (substantially in the same way as CoreDataBooks example) with a different predicate, based on selection the user made on the previous controller. ...

Determine uniqueness of a delegate across app domains, for use in hashing for a distributed memory cache

Currently looking into distributed memory cache solutions, such as Memcached and Microsoft's AppFabric caching. It seems to me that one of the difficult hurdles in implemented a distributed cache for an application is determining appropriate keys for the hash. A naive approach is to hard code hash keys in your application so that all i...

WPF - Custom Mark-up Extensions return RoutedEvents

Hello! I'm trying to create a generalized event for my Close buttons, where they have to close the window but before that set focus to the owner window. I don't want to have an event for every file for that, because that'd be pretty unpractical since I have 30+ windows in my application. (So if I wanted to change that behavior, i'd have ...

iphone make personal delegate

Hi all! I have this problem.... in my viewcontroller.h I defined my class like this: myClass* iR; and after: @property (nonatomic,retain) IBOutlet myClass* iR; into myClass.h I added this: @protocol myClassDelegate <NSObject> -(void) didLogon:(bool)isLogged; @end and after: @property (nonatomic, assign) id<myClassDelegate> dele...

Need help in Event Handling

I have a delegate delegate string Mathop<T,F>(T a,F b); and I am declaring an event like event Mathop<T,F> someevent; But here I am getting an error. It says 'T' could not be found. I want my Mathop delegate to work as an eventhandler for my event. What I am doing wrong here. ...

Why can't I define an Action in line in a method expecting a delegate ?

Hi, Given the following MSDN sample code, why can't I define the Action delegate "inline": public static void Main(string[] args) { Action someAction = () => Console.WriteLine("Hello from the thread pool!"); Task.Factory.StartNew(someAction); } ...so "inline" like: public static void Main(string[] args) { Task.Factory.S...

What does it mean by Event ?

I have learned delegate in dotnet that is referencing any function. What does it mean by event coceptually? Is it any reference ? It has a middle layer and use delegates internally. But, what is that middle layer ? Actually, what can we do using event ? or Why should we use it ? Why does event has no return type ? Why is it public by ...

C# recursive delegate declaration problem

* PLEASE SEE END FOR IMPORTANT EDIT * For various reasons I have something like: delegate void Task(QueueTask queueTask); delegate void QueueTask(Task task); Using Visual Studio Express 2008 this works more or less fine apart from in lambda expressions where it can't deduce if I try call and call queueTask() in the function without ...

Declaring delegate

Just realized that the delegates I am declaring are not declared with pointer type. so instead of this id <AddViewControllerDelegate> *delegate; I have this id <AddViewControllerDelegate> delegate; Why the last way is correct? Since self is pointer(I guess) then why delegate is not? ...

Objective-C delegate coding practices

I have some coding practices involving delegates that I'm not sure of. First of all, if a delegate protocol has no optional methods (all required), is it a recommended practice to use respondsToSelector: to check whether the delegate object implements that method? And second, do I need to check whether the delegate isn't nil before calli...

Is there an NSWindow notification/delegate method like "willShowWindow"?

Hi, I cannot seem to find it in the documentation but I'm looking for a way to run a method whenever a window is displayed on screen after launch of my app or after it has been closed and then reopened again. ...