delegates

Passing delegate function with extra parameters

自闭症网瘾萝莉.ら 提交于 2020-01-10 18:42:11
问题 I have a delegate which looks like the following: public delegate bool ApprovalPrompt(ApprovalType type, int receipt, params string[] info); I accept a delegate of this type as a parameter to the function I want to call. However, in one particular calling function, I want to pass some extra data to the function which matches this delegate. Here's the signature of the implementing function: private static bool LogApprovalNeeded(FraudFilterUtilities.ApprovalType type, int receipt, params string

Delegate - How to Use?

假如想象 提交于 2020-01-10 05:55:08
问题 I think I understand the logic behind a delegate. I got more the problem to use it. How many steps are involved? Do I have to use existing delegates? Or can I use my one ones? In my example I got the AppDelegate that created many views (Objects / View Controllers) of the same type. Each view should somehow call a method on the AppDelegate to close itself. This would happen when a button within the view is touched. The method call would include the reference of the view (self). So far I know

Custom UITableViewCell delegate pattern in Swift

半城伤御伤魂 提交于 2020-01-10 04:37:08
问题 I have a weird problem in a Swift + Objective-C problem. I'm implementing a UITableView and a custom cell with a delegate in swift, but as soon as my UITableViewController assign my cell delegate to self, it crash both my app and Xcode. Yeah each time I crash my app, Xcode crash too, no matter what, but this is another problem. Here is a part of my cell enum NewsCellActionType: Int { case Vote = 0 case Comments case Time } protocol NewsCellDelegate { func newsCellDidSelectButton(cell:

How to use delegate in NSStream?

£可爱£侵袭症+ 提交于 2020-01-10 04:29:24
问题 I am a newbie in Objective-C. I am trying to learn how to work with NSStream . I just used simple code from Apple Support. This code should open a stream from a file in my Desktop and show a simple message when the delegate is called by iStream. At the end of the code, I can see the status is correct, but the delegate never gets called. What am I missing? #import <Foundation/Foundation.h> @interface MyDelegate: NSStream <NSStreamDelegate>{ } - (void)stream:(NSStream *)stream handleEvent:

The exact moment iOS takes the view snapshot when entering background?

假如想象 提交于 2020-01-09 12:51:11
问题 I have a problem when putting my iPhone app to background by pushing the exit button, and then relaunching by tapping the launch icon on the home screen: the app's view does return to its initial state like I want it to, but before that it flashes the earlier, wrong view state onscreen briefly. Background My main view consists basically of a sequence of interlinked UIAnimateWithDuration calls. The behavior I want whenever any interruption occurs, is to reset the animation to its initial state

VB.NET Delegates and Invoke - can somebody explain these to me?

大憨熊 提交于 2020-01-09 09:38:36
问题 I'm new to the world of threading, but a few aspects of an app I'm working on require me to use a BackgroundWorker control to prevent the UI freezing up while it's doing some file operations. What I'm trying to do is update a couple of form labels from within the BackgroundWorker. Having never worked with this before I very quickly discovered that I can't access controls that weren't created within the same thread, so after a bit of research I've implemented the following code that seems to

VB.NET Delegates and Invoke - can somebody explain these to me?

人盡茶涼 提交于 2020-01-09 09:38:12
问题 I'm new to the world of threading, but a few aspects of an app I'm working on require me to use a BackgroundWorker control to prevent the UI freezing up while it's doing some file operations. What I'm trying to do is update a couple of form labels from within the BackgroundWorker. Having never worked with this before I very quickly discovered that I can't access controls that weren't created within the same thread, so after a bit of research I've implemented the following code that seems to

C# - Event keyword advantages?

陌路散爱 提交于 2020-01-09 06:24:05
问题 I've come to recently understand that a C# 'event' really is. It isn't really anything, honestly. To sum up my findings: The event keyword is simply a modifier that only applies to delegates. So, all the 'magic' of an event are the operations of a delegate. That's it. I've read through a lot of the Microsoft documentation, but there no sentence that summarizes in that manner so succinctly. To continue with my findings, delegate, class, and struct are all on the same 'level'. They are ways to

C# - Event keyword advantages?

↘锁芯ラ 提交于 2020-01-09 06:23:09
问题 I've come to recently understand that a C# 'event' really is. It isn't really anything, honestly. To sum up my findings: The event keyword is simply a modifier that only applies to delegates. So, all the 'magic' of an event are the operations of a delegate. That's it. I've read through a lot of the Microsoft documentation, but there no sentence that summarizes in that manner so succinctly. To continue with my findings, delegate, class, and struct are all on the same 'level'. They are ways to

In ObjectiveC using delegate how do I send a message without using a UIButton?

帅比萌擦擦* 提交于 2020-01-07 06:31:24
问题 I recently learned to use delegates to send messages from one class to another whenever a button is pressed and I'd like to find out how to send a message without a button action. Apple documentation suggests a likely method is performSelector:(SEL)aSelector; but I had no luck when I tried to use it. Instead, this is what I tried. In MicroTune.h , I defined a delegate and gave it a property @class Synth; @protocol TuningDelegate <NSObject> -(void)setTuning:(NSData *)tuningData; @end