delegates

No known instance method for selector--delegate issue?

我的梦境 提交于 2019-12-13 07:03:41
问题 I'm getting the above error, and I don't know why. The line where the error is flagged is: - (IBAction)cancelButton:(UIBarButtonItem *)sender { [self.delegate addActivityViewControllerDidCancel:self.thisActivity]; } I'm confused because there seems to be no problem with this method, immediately preceding: - (IBAction)saveButton:(UIBarButtonItem *)sender ... [self.delegate addViewControllerDidSave]; } ... } My protocol is declared like this in the associated header file: @protocol

Accessibility between Action and Delegate

淺唱寂寞╮ 提交于 2019-12-13 06:59:24
问题 In the code below I created a delegate named Mhd - just like the Action delegate. My question: if the two delegates are public , why only Action delegate is visible from another class and not Mhd ? static void Main(string[] args) { new Test().Yaser(); //this can be done new Test().mhd(); //this can not be done } class Test { public Action Yaser; public delegate void Mhd(); } //and Action definition is public delegate void Action(); any help is appreciated :) 回答1: For my answer to make sense,

Threads totally freezes the GUI

点点圈 提交于 2019-12-13 06:43:50
问题 private delegate void Runner(); //A delegate, but this attempt didn't work public void Run() { Stager.InstructionsMemory = InstructionsTextBox.Text.Split('\n'); Stager.InintializeLists(); InstructionThread = new Thread[Stager.InstructionsMemory.Length]; PipelineInitializor(); BlockingCollection<Func<object>>[] tasks = new BlockingCollection<Func<object>>[Stager.InstructionsMemory.Length]; PCounterLabelUpdate up = new PCounterLabelUpdate(PCounterLabelUpdater); MemoryUpdater MemUp = new

Delegate to replace repeating code

匆匆过客 提交于 2019-12-13 06:09:37
问题 I have 10 check boxes in a group box. The top check box labeled "All" checks the other 9 check boxes when checked is true for "All" In the other 9 checkboxes, I have essentially the same code. Here is a sample for two of the check boxes: private void ckDal_Click(object sender, EventArgs e) { if (ckDal.Checked == false) ckAll.Checked = false; } private void ckHou_Click(object sender, EventArgs e) { if (ckHou.Checked == false) ckAll.Checked = false; } I hate repeating the same code. How would I

Responder Chain but NOT delegate property passes value back to view controller from container

ⅰ亾dé卋堺 提交于 2019-12-13 05:26:31
问题 The following code should show two ways to pass information from an embedded controller (UICollectionView) back to a detailed view controller using either the Responder Chain OR delegate approach. Both approaches use the same protocol, and delegate method. The only difference is if I comment out the delegate?.method line in didSelectItemAtIndex path, the Responder Chain works. BUT, if I comment out the Responder Chain line in the didSelectItemAtIndex method, the uncommentented delegate?

return false on dynamically created element

好久不见. 提交于 2019-12-13 05:24:24
问题 I'm trying to prevent an event on dynamically created elements. I tried several ways but none worked. On deafult, a click on the div containing the class opens a menu, and I want to disable that. This is my code (please note I'm using jQuery 1.6.4 so I'm not able to use the "on" method). $(function() { $( document ).delegate( "span.highlight_mkt", "click", function() { return false; }); }); I have tried this using the "live" method as well but without any success. Any help would be much

C++/CLI marshaling .NET delegate to native delegate

北战南征 提交于 2019-12-13 05:13:35
问题 I am trying to pass a delegate with managed parameters to native code to be invoked. My code below runs ok, but the string output is garbage. Native Class Header #pragma once typedef void (* SegmentCreatedDelegate)(char** arg); public class SampleClass { public: SampleClass(void); ~SampleClass(void); void DoWork(SegmentCreatedDelegate callback); }; Code SampleClass::SampleClass(void) { } SampleClass::~SampleClass(void) { } void SampleClass::DoWork(SegmentCreatedDelegate callback) { for(int x

replace method in delegate string

江枫思渺然 提交于 2019-12-13 04:52:15
问题 i have got a little problem i received some data and show it in textbox to invoke it i used if (textBox1.InvokeRequired) { // this is worker thread updatetextBoxDelegate del = new updatetextBoxDelegate(updatetextBox); textBox1.Invoke(del, new object[] { data }); } my data is like name:sam age:10 now i want to split it and save these values in array or show in sperate textboxes i used replace method like string str = textBox1.text; str.Replace("name",""); and so on but the problem is replace

Compiler complains when Event has add & remove properties. Compiles OK without

白昼怎懂夜的黑 提交于 2019-12-13 04:48:23
问题 I'm modeling my C# 4.0 event handler logic after this SO answer and get the error ThresholdExceededEvent can only appear on the left hand side of += or -= Code private EventHandler<EventLogAlert> thresholdExceededEventDelegate; public event EventHandler<EventLogAlert> ThresholdExceededEvent { add { thresholdExceededEventDelegate += value; Console.WriteLine("add operation"); } remove { thresholdExceededEventDelegate -= value; Console.WriteLine("remove operation"); } } protected virtual void

Custom slider UI Swing

自作多情 提交于 2019-12-13 04:38:25
问题 I'm trying to create a custom extension of BasicSliderUI. I'm just trying to make the thumb a circle (note I'm in the Windows L&F). I've created a very simple implementation that just calls g.drawOval, but whenever I drag it, it leaves a "trail" behind. Any ideas why this is? thanks, Jeff 回答1: You need to call repaint on the whole thing, you cant just draw the oval on top of it. Swing will by default only repaint what needs to be repainted, which usually isn't the whole control. When are you