Hi,
I am trying to learn on how to use delegates efficiently in C# and I was just wondering if anyone can guide me through... The following is a sample implementation using delegates... All I am doing is just passing a value through a delegate from one class to another... Please tell me if this is the right way to implement... And also ...
I am learning delegates.I am very curious to apply delegates to the following chain-of-responsibility pattern.
Kindly help me the way to apply delegates to the following piece.
Thanks in advance.Thanks for your effort.
#region Chain of Responsibility Pattern
namespace Chain
{
public class Player
{
public string Name { ...
Can anyone explain what are the LINQ, Lambda, Anonymous Methods, Delegates meant?
How these 3 are different for each other?
Was one replaceable for another?
I didn't get any concrete answer when i did Googling
...
I wrote this code:
public static bool MyMethod(int someid, params string[] types)
{...}
How could I write that using Func?
public static Func < int, ?params?, bool > MyMethod = ???
...
I have two object:
@protocol ObjectADelegate
- (void)objectAfirst:(ObjectA *)obj;
- (void)objectAsecond:(ObjectA *)obj;
@end
@interface ObjectA : NSObject {
id<ObjectADelegate> delegate;
- (void)callSecond
{
[self.delegate objectAsecond:self];
}
@end
@interface ObjectB : NSObject <ObjectADelegate>{
ObjectA *myObjectA;
}
@impl...
Hi
This is not an actual Xcode error message, it is a warning that has been haunting me for
a long time. I have found no way of removing it and I think I maybe have overstepped some unwritten naming convention rule.
If I build a class, most often extending NSObject, whose only purpose is to do some task and report back when it has data...
I'm making some tabs and I want to have my own delegate for them but when I try to send an action to the delegate nothing happens.
I also tried following this tutorial:
link text
But it doesn't work for me :(
Here is my code:
TiMTabBar.h
@protocol TiMTabBarDelegate;
@interface TiMTabBar : UIView {
id<TiMTabBarDelegate> __de...
Whenever i am updating UI in windows form using delegate it gives me cross thread exception
why it is happening like this?
is there new thread started for each delegate call ?
void Port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
//this call delegate to display data
clsConnect(statusMsg);
}
protected ...
I'm having trouble handling the scenario whereby an event is being raised to a closed form and was hoping to get some help.
Scenario (see below code for reference):
Form1 opens Form2
Form1 subscribes to an event on Form2 (let's call the event FormAction)
Form1 is closed and Form2 remains open
Form2 raises the FormAction event
In For...
I've read two books, tons of examples. They still make next to no sense to me. I could probably write some code that uses delegates, but I have no idea why. Am I the only one with this problem, or am I just an idiot? If anyone can actually explain to me when, where, and why I would actually use a delegate, I'll love you forever.
...
I'm confused why this compiles:
private delegate int MyDelegate(int p1, int p2);
private void testDelegate()
{
MyDelegate imp = delegate
{
return 1;
};
}
MyDelegate should be a pointer to a method that takes two int parameters and returns another int, right? Why am I allowed to ass...
How do I make a delegate? I have a class called CustomSign. The class has a view associated with it. The view has 2 elements. A textfield and a uilabel. I want to copy the textfields data to the uilabel when you click the done button.
Here's my code in the CustomSign.m
I don't know how to make it a delegate.
-(void)textFieldDidEndEditi...
I am new to iPhone development. I am converting the date to the desired format and set it to the delegate and get its value in the another view. The session restarts when I tried to get the value from delegate. If I set the original date and not the formatted date in the set delegate, then i able to get the value in the another view. If...
I have a xib. the xib has a button that swaps another xib.
the second xib has a uitextfield and a uilabel.
how do I make the keyboard go away when I'm done typing? what do I need to wire or code? the second xib has it's own class (called CustomSign.m)
Inside CustomSign.m, I've implemented the following method
-(void)textFieldDidEndEd...
Where is there documentation on the treatment of arguments to BeginInvoke?
If I have a delegate (which wraps my handler function) that accepts an object as a parameter, does that object get copied or referenced by the asynchronously-called handler function?
delegate void MyDelegate(SomeObject obj);
// later on:
// invoke the delegate ...
private static Dictionary<Type, Func<string, object>> _parseActions
= new Dictionary<Type, Func<string, object>>
{
{ typeof(bool), value => {Convert.ToBoolean(value) ;}}
};
The above gives an error
Error 14 Not all code paths return a
value in lambda expression of type
'System...
Consider the code:
class Work
{
public void DoStuff(string s)
{
Console.WriteLine(s);
// .. whatever
}
}
class Master
{
private readonly Work work = new Work();
public void Execute()
{
string hello = "hello";
// (1) is this an ugly hack ?
var thread1 = new Thread(new Para...
I'm integrating the latest version of the admob sdk (version 20100412) into my app.
The ads get displayed, but I need the app to make some changes when an ad is clicked and admob displays a full-screen browser. However, none of the callback methods (willPresentFullScreenModal, didPresentFullScreenModal, willDismissFullScreenModal, and d...
In CLR via C#, Jeffrey Richter gives the following example of delegate chaining (pg. 406):
internal delegate void Feedback(Int 32 value);
Feedback fb1 = new Feedback(method1); // in the book, these methods
Feedback fb2 = new Feedback(method2); // have different names
Feedback fb3 = new Feedback(method3);
Feedback fbChain = null;
fb...
I'm interested in knowing how others have implemented/designed database & web services in their iphone app and how they simplified it for the entire application. My application is dependent on these services and I can't figure out a efficient way to use them together due to the (semi)complexity of my requirements. My past attempts on com...