delegates

How can my code get notified when the user pastes or drags an image into NSImageView?

I have an instance of NSImageView. I have told InterfaceBuilder to allow the user to paste or drag an image into this view. This works. However, I don't see a way in the NSImageView or related documentation to get notified when this actually happens. I was expecting a delegate or some such, but I have been unable to find it. Any ideas? ...

Why can't I use/cast an Action for/to a ThreadStart?

Both are delegates and have the same signature, but I can not use Action as ThreadStart. Why? Action doIt; doIt = () => MyMethod("test"); Thread t; t = new Thread(doIt); t.Start(); but this seams to work: Thread t; t = new Thread(() => MyMethod("test")); t.Start(); ...

CreateDelegate with unknown types

Hello, I am trying to create Delegate for reading/writing properties of unknown type of class at runtime. I have a generic class Main<T> and a method which looks like this: Delegate.CreateDelegate(typeof(Func<T, object>), get) where get is a MethodInfo of the property that should be read. The problem is that when the property return...

Delegate within a delegate in VB.NET.

I am trying to write a VB.NET alternative to a C# anonymous function. I wish to call Threading.SynchronizationContext.Current.Send which expects a delegate of type Threading.SendOrPostCallback to be passed to it. The background is here, but because I wish to both pass in a string to MessageBox.Show and also capture the DialogResult I ne...

how do i add two delegates to a ui element at run time?

Hi everyone, im trying to implement some behaviors when a mapview element scrolls... by coding a delegate for the scrollview inside of a mapview. so, right now, i got a pointer to the scroll view used by the map view in my code. however, i wish to set the delegate of this scroll view inside the map view, but the issue is that the ...

Memory management, and async operations: when does an object become nil?

I have a view that will be displaying downloaded images and text. I'd like to handle all the downloading asynchronously using ASIHTTPRequest, but I'm not sure how to go about notifying the view when downloads are finished... If I pass my view controller as the delegate of the ASIHTTPRequest, and then my view is destroyed (user navigates...

call method in a subclass of UIView

Hey, I've got a UIViewController and an own class, a subclass of UIView. In my ViewController I make a instance of the uiview. If I tap the uiview a function gets called within it and an overlay appears. TO get rid of that overlay later the user has to tap somewhere on the screen(besides the instance of my class) How do I tell my clas...

uitableview delegate methods are not called

hi all i got the problem that the tableview methods are not called the first time the tableview is shown. if i switch back to the previous view and then click the button to show the tableview again, the methods are called this time. i've to say that i show an actionsheet while the tableview is loading. the actionsheet i call in the Vie...

iphone setting UITextView delegate breaks auto completion

Hi there! I have a UITextField that I would like to enable auto completion on by: [self.textView setAutocorrectionType:UITextAutocorrectionTypeYes]; This works normally, except when I give the UITextView a delegate. When a delegate is set, auto complete just stops working. The delegate has only the following method: - (void)textView...

Create a new delegate class for each asynchronous image download?

First, I'm using an NSURLConnection to download JSON data from twitter. Then, I'm using a second NSURLConnection to download corresponding user avatar images (the urls to the images are parsed from the first data download). For the first data connection, I have my TwitterViewController set as the NSURLConnection delegate. I've created a...

Delegate Instantiation -Clarification

When i have delegate like public delegate void PrintMe(); (1) PrintMe a = delegate() { MessageBox.Show("Hello"); }; a(); (2) PrintMe b = () => { MessageBox.Show("Hello"); }; b(); (3) PrintMe c = new PrintMe(HelpMe); c(); static void HelpMe() { MessageBox.Show("Help Me"); } for (1) and (2) I did not instatntiate the delegate it ...

Array reverse and Array sort on One int array and store into another array using delgate

Array reverse and Array Sort on an int array and store into another array using a delegate. We have to accept the elements from the user ...

iPhone: Sharing protocol/delegate code

I have the following code protocol snippets: @protocol FooDelegate; @interface Foo : UIViewController { id delegate; } ... @protocol FooDelegate ... // method 1 ... // method 2 ... @end Also, the following code which implements FooDelegate: @interface Bar1 : UIViewController { ... } @interface Bar2 : UITableViewCo...

Best practice for controlling a busy GUI

Suppose a GUI (C#, WinForms) that performs work and is busy for several seconds. It will still have buttons that need to remain accessible, labels that will change, progress bars, etc. I'm using this approach currently to change the GUI when busy: //Generic delegates private delegate void SetControlValue<T>(T newValue); //... public v...

How Dispatcher differs from the background thread ?

How Dispatcher concept in .NET 3.5 in WPF differs from the background thread in .NET 2.0 ? For example what will be difference between statements below: delegate.Invoke/BeginInvoke AND this.dispatcher.Invoke/BeginInvoke ...

Traditional loop versus Action delegate in .NET

After learning about the Action delegate in C# I've been looking for ways I can best use it in my code. I came up with this pattern: Action<string> DoSomething = (lSomething) => { // Do something }; DoSomething("somebody"); DoSomething("someone"); DoSomething("somewhere"); If I were to have used a traditional loop, it would look ...

Moq a function with 5+ parameters and access invocation arguments.

I have a function I want to Moq. The problem is that it takes 5 parameters. The framework only contains Action<T1,T2,T3,T4> and Moq's generic CallBack() only overloads Action and the four generic versions. Is there an elegant workaround for this? This is what I want to do: public class Filter : IFilter { public int Filter(...

Can someone distill into proper English what a delegate is?

Can someone please break down what a delegate is into a simple, short and terse explanation that encompasses both the purpose and general benefits? I've tried to wrap my head around this and it's just not sinking in. ...

DataGridView cell not redrawing when value changed asynchronously

I have a DataGridView whose cell values are changed via callback functions that are invoked asynchronously. In one case, I have a callback in the form of an Action<T>. I noticed that if I have a method public void MyMethod(T data) { } and I do: UpdaterObject.AddCallback(MyMethod); it works fine, but if I pass in the callback in this ...

Need to Release UIWebView Delegate?

I have a UIWebView named wView. I want to use webViewDidFinishLoad: in my class, so I am setting the class as the delegate for wView by using this line: wView.delegate = self; Everything loads properly, but when I close the UIWebView, the App crashes. If I comment out the wView.delegate = self, it works and does not crash, but then I ...