delegates

Using delegates for iphone 3.0 classes on older versions, specially the MKReverseGeocoderDelegate

I'm wondering what happens when I use a MKReverseGeocoderDelegate in my ViewController, but the application is running in 2.2.1. Because I'm supporting 2.2.1 but using 3.0 as Base SDK. I have already added the framework as soft linking to support working on 2.2.1 and I understand I have to prepare the code to check if the MKReverseGeoco...

C# - Is it possible to have multiple method signatures for an Action<>?

In C#, is it possible to have an object that has multiple method signatures for an Action<> or delegate? Like this: class Foo { public Action<string> DoSomething; public Action<string, string> DoSomething; } class Bar { public Bar() { Foo f1 = new Foo(); f1.DoSomething = (s) => { Console.Write(s) }; ...

Explain ASP.NET Events

See Also: understanding events and event handlers in C# As a web dev, I don't typically have to get into building my own events for objects, since most are inherent in the page. However, now I'm into a pretty complex (web) project where I think I may have to use them. I just read a chapter out of Pro VB 2008 and the .NET 3.5 Pl...

Is there an equivilent of C# Anonymous Delegates in Java?

In C#, you can define small pieces of code called delegates anonymously (even though they are nothing more than syntactic sugar). So, or example, I can do this: public string DoSomething(Func<string, string> someDelegate) { // Do something involving someDelegate(string s) } DoSomething(delegate(string s){ return s += "asd"; }); D...

how to detect and program around shakes for the iphone

I'm trying to implement the shake "tutorial" on this page, but I think I'm missing something. I copied his accelerometer function into myAppViewController.m file and put some nslogs in there to see if it even gets into the function when I use the simulators "shake" function. Nothing shows up in the debug console. http://mithin.in/2009...

Trying to Access Application Delegate Variables / Properties

I am using a variable/propery of my application delegate as a global. (I don't want to deal with a singleton class.) I am trying to write a #define statement in my Application Delegate class. If I type: [UIApplication sharedApplication] in my app delegate class, code hinting does not recognize sharedApplication. But if I type th...

Difference Between Application Delegates

What is the difference between: [[UIApplication sharedApplication] delegate] and UIApplicationDelegate ...

Where do I put my C# delegate declaration, in a file of its own?

Out of habit I tend to put classes/structs/enumerations in separate files when not nested. For delegates, it seems like overkill to create a seperate file for a one liner: public delegate string MyDelegateThatIsNotNestedInAnyClass ( string par ); I usually add it to the bottom of the most closely related class file. I was just wonde...

Can you use .net 3.5 Action or Func as Marshalled unmanaged delegates?

After reading Dynamically calling unmanaged dlls in .net I've been trying to modify the code to my liking. I made a class that implements idisposable to wrap load calls in and free them when needed. However I can't seem to figure out the syntax if it is possible to use anonymous delegates with it. var loaded=DynamicLibraryLoader.TryLo...

Passing parameter to delegate function

I currently have this: instance = new Class1<Type1>( "param1", () => new ViewDataDictionary<Type2>( new Class2 { Prop1= CreateList(new List<long> { 234 }), Prop2= CreateList(new long[] { 234 }) ...

How do I Unregister 'anonymous' event handler

Say if I listen for an event: Subject.NewEvent += delegate(object sender, NewEventArgs e) { //some code }); Now how do I un-register this event? Or just allow the memory to leak? ...

Little confused on Delegates in Objective-C

I know a good bit of Objective-C and I'm working on a iPhone SDK book (coming from a Obj-C book that just did console programs). It attempted to explain delegates though it was rushed and didn't really understand what it was trying to convey. I'm a little confused on what they are and when you would use them. Basically it said they ar...

Will Delegate with params keyword match any method?

Hi! I'm trying to get the following thing done: public delegate void SomeMethod(params object[] parameters); That's my delegate. And i have some method that will run this SomeMethod delegate (whatever's passed) and return me the timespan of execution. public TimeSpan BenchmarkMethod(SomeMethod someMethod, params object[] paramete...

Use the Windows-key for another purpose in C#

Is there a way to disable the standard built-in function of the Windows-Key (open the start-menu) and activate instead of that function for instance a delegate or an event in C#? I want to use this as an additional key in a full-screen app. ...

C#:Creating Multicast delegate with boolean return type

Hai Techies, in C#, how can we define the multicast delegate which accepts a DateTime object and return a boolean. Thanks ...

Responding to changes in a SortedDictionary.

I've created a new class that inherits from SortedDictionary: public partial class ListIncomeWeight : SortedDictionary<string, double> { public Guid Identity { get; set; } } This list is combined with a few dozens of other lists, where the other lists will keep track if they already calculated with this list or not. For that purp...

Asp.net page - user control communication

I have a page Product.aspx,there I have a user control ProductDisplay.ascx which has been created by drag and drop. Now when a button is clicked in ProductDisplay.ascx,I want a logging function to be called which is in Product.aspx. To achieve this I have used delegates on ProductDisplay.ascx public delegate void LogUserActivity(Prod...

different delegate uses

Possible Duplicate: What is the difference between a delegate and events? Possible Duplicate: Difference between events and delegates and its respective applications (copied from this duplicate) When i have to raise an event i do this public delegate void LogUserActivity(Guid orderGUID); public event LogUserActiv...

Difference between Delegate.Invoke and Delegate()

delegate void DelegateTest(); DelegateTest delTest; Whats the difference between calling delTest.Invoke() and delTest()? Both would execute the delegate on the current thread, right? ...

Visual Studio shortcut to auto-add event delegate methods

In C# adding event handler methods is very easy. You just type "object.event +=" and then press tab twice. Is there anything like this for VB projects? Note: This is for dynamically created controls or controls that are not declared WithEvents. ...