delegates

How to change RootViewController (in AppDelegate) from within CustomViewController?

≯℡__Kan透↙ 提交于 2020-01-01 03:39:10
问题 Good day, My app has authorization form (SigninController) which is loaded in AppDelegate, and after signing in (checking is in SigninController.m) TabBarController should appear (as main view of application). How can I change controller from Signin to TabBar and where ?? - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { SigninController *aSigninController = [[SigninController alloc] initWithNibName:@"SigninView" bundle:nil]; self

Multicast delegate C#

元气小坏坏 提交于 2020-01-01 03:31:10
问题 Am studying about delegates. As I read. I learned that adding more than one function in a delegate is called multicast delegate. Based on that I wrote a program. Here two functions (AddNumbers and MultiplyNumbers) I added in the MyDelegate. Is the below program is an example for multicast delegate ?. public partial class MainPage : PhoneApplicationPage { public delegate void MyDelegate(int a, int b); // Constructor public MainPage() { InitializeComponent(); MyDelegate myDel = new MyDelegate

Are delegates not just shorthand interfaces?

夙愿已清 提交于 2020-01-01 02:53:04
问题 Suppose we have: interface Foo { bool Func(int x); } class Bar: Foo { bool Func(int x) { return (x>0); } } class Baz: Foo { bool Func(int x) { return (x<0); } } Now we can toss around Bar and Baz as a Foos and call their Func methods. Delegates simplify this a little bit: delegate bool Foo(int x); bool Bar(int x) { return (x<0); } bool Baz(int x) { return (x>0); } Now we can toss around Bar and Baz as Foo delegates. What is the real benefit of delegates, except for getting shorter code? 回答1:

Is there a case where delegate syntax is preferred over lambda expression for anonymous methods?

拜拜、爱过 提交于 2020-01-01 02:17:50
问题 With the advent of new features like lambda expressions (inline code), does it mean we dont have to use delegates or anonymous methods anymore? In almost all the samples I have seen, it is for rewriting using the new syntax. Any place where we still have to use delegates and lambda expressions won't work? 回答1: Yes there are places where directly using anonymous delegates and lambda expressions won't work. If a method takes an untyped Delegate then the compiler doesn't know what to resolve the

Why can't I put a delegate in an interface?

☆樱花仙子☆ 提交于 2019-12-31 08:56:46
问题 Why can't I add a delegate to my interface? 回答1: You can use any of these: public delegate double CustomerDelegate(int test); public interface ITest { EventHandler<EventArgs> MyHandler{get;set;} CustomerDelegate HandlerWithCustomDelegate { get; set; } event EventHandler<EventArgs> MyEvent; } 回答2: A Delegate is just another type, so you don't gain anything by putting it inside the interface. You shouldn't need to create your own delegates. Most of the time you should just use EventHandler,

How do I form a good predicate delegate to Find() something in my List<T>?

早过忘川 提交于 2019-12-31 08:13:32
问题 After looking on MSDN, it's still unclear to me how I should form a proper predicate to use the Find() method in List using a member variable of T (where T is a class) For example: public class Car { public string Make; public string Model; public int Year; } { // somewhere in my code List<Car> carList = new List<Car>(); // ... code to add Cars ... Car myCar = new Car(); // Find the first of each car made between 1980 and 2000 for (int x = 1980; x < 2000; x++) { myCar = carList.Find(byYear(x)

How do I form a good predicate delegate to Find() something in my List<T>?

*爱你&永不变心* 提交于 2019-12-31 08:13:03
问题 After looking on MSDN, it's still unclear to me how I should form a proper predicate to use the Find() method in List using a member variable of T (where T is a class) For example: public class Car { public string Make; public string Model; public int Year; } { // somewhere in my code List<Car> carList = new List<Car>(); // ... code to add Cars ... Car myCar = new Car(); // Find the first of each car made between 1980 and 2000 for (int x = 1980; x < 2000; x++) { myCar = carList.Find(byYear(x)

unable to receive callback from second view controller

帅比萌擦擦* 提交于 2019-12-31 05:21:07
问题 I have got two view controllers. Im trying to pass data to the previous viewcontroller I have the following code in my second view controller CEPeoplePickerNavigationController @class CEPeoplePickerNavigationController; @protocol CEPeoplePickerNavigationControllerDelegate <NSObject> - (void)previousViewController:(CEPeoplePickerNavigationController *)controller itemToSend:(NSString *)item; @end @interface CEPeoplePickerNavigationController : UIViewController <UITableViewDelegate

Delegate Method to UItableViewCell Swift

放肆的年华 提交于 2019-12-31 04:28:08
问题 I have a Social Network Feed in form UItableView which has a cell. Now each cell has an image that animates when an even is triggered. Now, This event is in form of a string, will be triggered at every cell. the options for the event are defined in another class(of type NSObject). My issue: I constructed a protocol delegate method in table view, which will be called whenever the event is triggered for each cell. Then, I define this function in UITableViewCell Class, since my the image will be

Explaning syntax for @property id<delegateName>

我的梦境 提交于 2019-12-31 04:04:08
问题 I see a lot of code references when writing delegates using something likes @property (nonatomic, weak) id<mySuperCoolDelegate> delegate; normally where id<mySuperCoolDelegate> is, is the data type of the property. So the questions are: Is my understanding correct, that above syntax is telling the compiler data type of the id is mySuperCoolDelegate? Any other examples where this sort of code (data type specified for id) could be used? Thanks! 回答1: This syntax tells the compiler that delegate