delegates

How to make a generic delegate EndInvoke?

China☆狼群 提交于 2019-12-26 18:12:13
问题 So I have the following: private delegate Foo1 GetFooAsync1(Foo1 foo1); private delegate Foo2 GetFooAsync2(Foo2 foo2); private delegate Foo3 GetFooAsync3(Foo3 foo3); private delegate Foo4 GetFooAsync4(Foo4 foo4); private FooAsync1 foo1; private FooAsync2 foo2; private FooAsync3 foo3; private FooAsync4 foo4; And the lists goes on and on, then inside a method I don't want to put a try catch on each EndInvoke, because sometimes it does throw an exception but it shouldn't stop the system, and

Proper way of creating new objects which are copies of NSDictionary and NSArray objects defined in app delegate

你离开我真会死。 提交于 2019-12-25 18:31:08
问题 I am wondering what the correct way is to make a copy of an object defined in the app delegate or a singleton object. In short, I am making an app which requires a user to login. This login view is just a modal view controller on top of the 'real' app, which consists of a tabbarcontroller, plus some tableview controllers. After a successful login, there is send a data request to a remote server, and the modal view controller is dismissed, revealing the tabbar controller and table views

Obj-C: I'm trying to understang delegates, but I'm messing something [closed]

两盒软妹~` 提交于 2019-12-25 18:30:47
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I saw the example with Flower an MyGarden, but when I try to make something similar it doesn't work. My code: ClassA.h: #import <Foundation/Foundation.h> @protocol CommDelegate <NSObject> @required -(void)funcB;

Change label text color using delegate

三世轮回 提交于 2019-12-25 18:20:04
问题 I have two view controller, ParentViewController have label that updated using SecondViewController . Now I want to change ParentViewController 's label text color from ChildViewController , for that i am using protocol and delegate but it shows error. My code is like this: ChildViewController.h @protocol ViewControllerDelegate -(void) updateLabel; @end @interface ChildViewController : UIViewController<UITextFieldDelegate,UITextViewDelegate> { id <ViewControllerDelegate> delegate; } @property

UINavigationController popToRootViewController method cannot be called by a delegate?

℡╲_俬逩灬. 提交于 2019-12-25 18:17:59
问题 I have a UINavigationController which works great. Each view controller has its own button that pops the stack back to its root which also works great. However, I'd like to also be able to pop the stack back to its root by pressing a button on the tab bar (which is obviously in an entirely different class outside of the navigation stack). Therefore, I created a delegate in the tab bar class which finds the view controller at the top of the stack and calls the method in that view controller to

vb.net: listbox.items.add() throws exception in same class

寵の児 提交于 2019-12-25 18:12:58
问题 I'm not even sure I understand this situation enough to come up with a proper title. I come from a modest understanding of VB6 and having to climb a steep learning curve for VB 2010. I am trying to create a multi-client server program that will communicate with my Enterprise iPhone app. I found a relatively simple example to build upon here: http://www.strokenine.com/blog/?p=218. I have been able to modify the code enough to make it work with my app, but with one glitch: I can't get access to

Cannot get delegate to work between my views

走远了吗. 提交于 2019-12-25 14:24:32
问题 I need to call some methods from one view to another, and I can't seem to get it to work. What am I doing wrong? Here's my ViewController.h #import <UIKit/UIKit.h> #import "mySettings.h" @protocol ViewControllerDelegate <NSObject> @required - (void) getDefaults; - (void) updateSubTotal: ( float ) value; @end @interface ViewController : UIViewController <UIPickerViewDataSource, UIPickerViewDelegate> { id <ViewControllerDelegate> delegate; } @property (retain) id delegate; . . (other

Assigning generics function to delegate in Typescript

余生颓废 提交于 2019-12-25 09:28:26
问题 I can't get this simple code snippet to compile in Typescript (1.8) function test<T>(a: string, input: T): T { return input } const xyz: (a: string, b: number) => number = test<number> I have a function that takes a delegate, but converting the generics function into that delegate format requires me to perform this extra step: const xyz: (a: string, b: number) => number = (a,b) => test<number>(a,b) ... which does not seem ideal to me. Any ideas why this does not work, or if there is another

Delegation in NSObject Classes

泪湿孤枕 提交于 2019-12-25 09:00:02
问题 I have used delegates in Viewcontrollers and they worked well but now I want the delegation process between my two NSObject classes. But getting crash : fatal error: unexpectedly found nil while unwrapping an Optional value Here is what I am doing : Basic Device Class : class basicDevice : NSObject, CBPeripheralDelegate { public static let NOTIFICATION_SERVICES_DISCOVERED = Notification.Name(rawValue: "NOTIFICATION_SERVICES_DISCOVERED") private var listOfServices:[String:[String]] = [:]

How to call a method from a UIViewController thats already on the UINavigationController stack

一世执手 提交于 2019-12-25 08:57:36
问题 I have a UIViewController on a UINavigationStack and from this UIView I load another view not onto the stack but as a subview. This view that I load is just a preferences view for the app that I overlay onto what ever is showing. i.e. myViewController <- on the stack button touch loads as a subview to myViewController + prefrencesViewController My question is, is there a way to call a method thats in myViewController from prefrencesViewController? I am trying to use delegates and protocols