delegates Questions
8
Solved
I have some code:
public delegate int SomeDelegate(int p);
public static int Inc(int p) {
return p + 1;
}
I can cast Inc to SomeDelegate or to Func<int, int>:
SomeDelegate a = Inc;
Func<...
2
What are the use cases for Delegates.observable when we can just use property setters?
var foo by Delegates.observable("hell0") { prop, old, new ->
// react to changes in foo
}
var bar = "...
6
Solved
After updating Xcode 7, some of my viewcontrollers' names changed to Delegate Scene, what to do about this? Thanks!
Changing the title doesn't help
Fluky asked 17/9, 2015 at 5:11
3
Solved
I want to check if I already have a delegate in my removeDelegate method before removing.
How do I do that?
Here's what I've got so far:
protocol LocationManagerDelegate {
func locationManagerD...
3
Solved
This has been asked before (I think), but looking through the previous answers I still haven't been able to figure out what I need.
Lets say I have a private method like:
private void GenericMeth...
2
Solved
I just started with .net core and found Action<T> used everywhere. I have provide sample code from Swagger code block below. My question is what is the use of using Action<T> here? I ne...
5
Solved
I have...
Func<string> del2 = new Func<string>(MyMethod);
and I really want to do..
Func<> del2 = new Func<>(MyMethod);
so the return type of the callback method is vo...
4
While using UITableView there are two types of methods ie, datasource and delegates still both supposed to be connected to the same parent view controller class.
Is there any way to define delega...
Pennant asked 5/8, 2017 at 15:22
10
Solved
I don't see advantages of using events over delegates, other than being syntactical sugar. Perhaps I am misunderstanding, but it seems that event is just a placeholder for delegate.
Would yo...
5
Solved
Why is it necessary to make a function STATIC while using delegates in C# ?
class Program
{
delegate int Fun (int a, int b);
static void Main(string[] args)
{
Fun F1 = new Fun(Add);
int Res= ...
Inessa asked 19/2, 2010 at 19:26
3
Solved
I use the following code to request a list of products as per the In-App Purchase Programming Guide. It used to work fine in my iPhone application, however now it crashes every time the product lis...
Lamellicorn asked 24/7, 2010 at 9:43
2
Solved
This may be a bit difficult to describe, so I'll try to give a concrete example of what I'm trying to do.
Suppose we have a Facade interface and class (in Java), like this:
interface FacadeInterf...
Comment asked 9/6, 2017 at 9:34
6
Solved
Once it is compiled, is there a difference between:
delegate { x = 0; }
and
() => { x = 0 }
?
Petroglyph asked 18/11, 2008 at 18:38
8
Solved
Is it possible to define a class in C# such that
class GenericCollection<T> : SomeBaseCollection<T> where T : Delegate
I couldn't for the life of me accomplish this last night in .NE...
Lecia asked 10/10, 2008 at 15:42
3
Solved
So when I write something like this
Action action = new Action(()=>_myMessage = "hello");
Refactor Pro! Highlights this as a redundant delegate creation and allows me to to shorten it to
Act...
1
Solved
To start with, this is not the same as Why is Func<> created from Expression> slower than Func<> declared directly? and is surprisingly just the opposite of it. Additionally, all links and qu...
Promenade asked 3/5, 2018 at 7:53
1
As to my understanding, the idea of delegating an implementation in Kotlin is to avoid code that looks like this:
class MyClass(val delegate : MyInterface) : MyInterface
{
override fun myAbstract...
Mitten asked 1/1, 2018 at 23:29
1
I am trying to handle "google sign in" in singleton helper class.
I have LoginHelper, and a method which handles logins with completion handler. As you know Google Sign have delegate methods. When...
Sclerite asked 28/4, 2018 at 18:54
2
Solved
Obviously, Java does not have delegates or functions as first class values and uses interfaces instead, but what is the closest interface to the Func<> or Action<> .NET delegates? There is Ru...
3
Solved
I have this method in my code:
Private Sub Display()
Received.AppendText(" - " & RXArray)
End Sub
Whats the difference between this 2 calls:
Me.Invoke(New MethodInvoker(AddressOf Display))...
Huckleberry asked 18/7, 2013 at 7:52
1
Is there any way to convert an existing Func delegate to a string like that:
Func<int, int> func = (i) => i*2;
string str = someMethod(func); // returns "Func<int, int> func = (i) =...
2
Solved
If I want to do a "fire and forget" of some code, but still want to ensure that my memory is cleaned up (per Why does asynchronous delegate method require calling EndInvoke?), will the following ac...
Decaliter asked 12/4, 2013 at 9:23
5
Solved
4
I have a class that requires a way to retrieve a random integer value with a maximum. I don't want this class to depend on a specific way to retrieve that random value (such as system.random). Woul...
2
Solved
To my surprise I have discovered a powerful feature today. Since it looks too good to be true I want to make sure that it is not just working due to some weird coincidence.
I have always thought t...
© 2022 - 2024 — McMap. All rights reserved.