delegates

Javascript: How can I mix in methods of other Objects B, C to my Object A without copying but with linking?

扶醉桌前 提交于 2019-12-24 15:27:24
问题 If I create an Object A: let A = {}; And want to mix in methods from other Objects B and C: let B = { foo() { alert("Boo!"); } }; let C = { bar() { alert("No!"); } }; Normally I would call: Object.assign(A, B, C); Then I change my function foo: Object.assign(B, { foo() { alert("Hooray!"); } }); Objcect.assign(C, { bar() { alert("Yes!"); } }); After that I call foo or bar: A.foo(); // Actual output: "Boo!", desired: "Hooray!" A.bar(); // Actual output: "No!", desired: "Yes!" So far I found out

facebook fbDidLogin outside appdelegate

落花浮王杯 提交于 2019-12-24 15:01:21
问题 I have read many questions about the facebook login but until not I didnt succeed on solving my problem. I have made a few apps so far but I have never messed with the appDelegate before. The thing is that I want to call the fbDidLogin method that is inside my class other than delegate. Until now, fbDidLogin is being called in the appDelegate, but I want to be able to change the view and ask for user info after the login happens. My code so far: AppDelegate: - (BOOL)application:(UIApplication

Delegation - Change variables from different viewsControllers

半腔热情 提交于 2019-12-24 12:51:18
问题 I have an UIImageView (img) on the container2View as an IBOutlet. How can I change the img.image and refresh the view from other container (containerView)? We have to use delegation mainController class mainController: UIViewController, containerDelegate { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { switch segue.identifier! { case

Send a Delegate message from UIPopover to Main UIViewController

廉价感情. 提交于 2019-12-24 11:15:09
问题 I'm trying to use a Button in my UIPopover to create a UITextView in my Main UIViewController the code I have looks something like this ( PopoverView.h file): @protocol PopoverDelegate <NSObject> - (void)buttonAPressed; @end @interface PopoverView : UIViewController <UITextViewDelegate> { //<UITextViewDelegate> id <PopoverDelegate> delegate; BOOL sendDelegateMessages; } @property (nonatomic, retain) id delegate; @property (nonatomic) BOOL sendDelegateMessages; @end Then in my PopoverView.m

uidatepicker in uipopover delegate

无人久伴 提交于 2019-12-24 10:46:14
问题 I am trying to insert a uipopover with uidatepicker in it with two buttons - Cancel and Done. I was able to design the layout using storyboard with the help of UIDatePicker in UIPopover and How can I show a UIDatePicker inside a Popover on iPad using StoryBoard? But, I am not able to get the date from uidatepicker to uiviewcontroller when Done button is pressed. I am new to ios programming and i find delegate methods very confusing. Could somebody shed some light? Help much appreciated. Thank

Unresolved external symbol, with home-made delegate

心不动则不痛 提交于 2019-12-24 10:19:37
问题 I have a function Foo which takes a 2-parameter function as a parameter: void Foo(void (*fcn)(int, int*)); However, the type of function which I want to pass in ( func ) only takes 1 parameter * . typedef void (__stdcall *FuncCallBack)(int a); void Caller(FuncCallBack func) { Foo(????); } In C#, I would do something like: Foo((a,b) -> func(a)); I'm trying to do something similar with a delegate class (having worked out that I can't have a pointer to a bound member function, I've switched to

Monotouch/iOS: which place is the best one to unsubscribe the delegate

青春壹個敷衍的年華 提交于 2019-12-24 10:07:37
问题 The best method in iOS to subscribe a event is ViewDidLoad, but when dismiss the view , the ViewDidUnload() is not called(only when the memory warning.) Which place is the best to unsubscribe the event? (In the subviewController I subscribe a event that reference the MainViewController, When open the subview twice, I receive two event trigger because the unsubscribe in viewdidunload() is never called.) How about with subscribe/unsubscribe in ViewWillAppear/ViewWillDisapper? public override

UIView needs to push a UIViewController (delegation)

烈酒焚心 提交于 2019-12-24 08:59:48
问题 I'm having a hard time getting my head around custom delegation - I would be most grateful if someone could help me: I have a UIViewController with a tab bar controller, and each of these contains a subclassed UIView. In one of the views, I have a UIButton in which I want to load a UIDocumentInteractionController. I already have the code to do this second part, as the document controller needs access to a UIViewController in order to get pushed to the stack. But how can my UIView get access

Passing data back :Delegate method not called

别来无恙 提交于 2019-12-24 08:57:29
问题 I am working on an app that connects with google docs using oauth 2.0, once the user has connected, He clicks a button that goes to a tableView to show all the documents. For this I am using a segue and passing data forward. Now I want the user to select one document, put a checkmark on it and return to the viewcontroller passing data back and display wich document was selected. I read that for passing data back I needed to use a protocol and a delegate. I followed this: Passing Data between

swift : UIPickerViewController delegates not called after Class-Extraction

别来无恙 提交于 2019-12-24 08:30:01
问题 I am working on an app which requires user to take selfie of pick Images from different ViewController. I want to extract class just for this purpose. But after extraction of class the delegate methods of UIPickerViewController are not being called. right now, I have a class called MultiMediaManager inside MultiMediaManager.swift file. class MultiMediaManager: NSObject, UIImagePickerControllerDelegate, UINavigationControllerDelegate { let imagePicker = UIImagePickerController() var