delegates

Pass Data between two view controllers using 'Delegation' : Objective-C

妖精的绣舞 提交于 2020-01-01 17:09:37
问题 I am implementing an library(.a), and I want to send notification count from library to app so they can show in their UI, notification count. I want them to implement the only method like, -(void)updateCount:(int)count{ NSLog(@"count *d", count); } How can I send the count from my library continuously so they can use it in updateCount method to show. I searched and come to know about call back functions. I have no idea how to implement them. Is there any other way to do this. 回答1: You have 3

Can you pass generic delegate without the type parameter?

☆樱花仙子☆ 提交于 2020-01-01 16:47:21
问题 I have three projects MVC Web application Service application which is kind of two layers business/repository Entity framework (all EF configuration lives here) MVC references > service Service references > EF I have these three methods currently that do some work. public bool StoreUpload<T>(UploadInformation information) where T : class, IUploadEntity { } public bool RemoveUpload<T>(UploadInformation information) where T : class, IUploadEntity { } public bool CommitUpload<T>

AppDelegate or AppController

岁酱吖の 提交于 2020-01-01 10:02:47
问题 While reading cocoa tutorials i've noticed that some of the tutorials use AppDelegate and some AppController for defining IBActions that open various windows that use subclasses of NSWindowController . Is there some sort of rule of thumb for this? 回答1: It's just a class name. AppDelegate implies that the class's main duty is as NSApplication's delegate, whereas AppController seems to imply a broader range of responsibility. 回答2: I create one class that is solely my app delegate, and

How to set a delegate in a different class

那年仲夏 提交于 2020-01-01 09:58:27
问题 I'm working with NSXMLParser that parses a xml document. You have to set the delegate which we would be called every time the parser finds an element. The examples I've looked at all set the delegate to be the same class that's createing: NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:filename]; [parser setDelegate: self]; Other examples set the delegate to be the parent. What if I want another class (not related to the same class) to handle the delegate. What is the syntax

Sending Class to Parameter of Incompatible Type 'id<UIWebViewDelegate>' Warning?

烈酒焚心 提交于 2020-01-01 09:39:30
问题 I wasn't expecting my program to put up a fuss when I wrote this line of code: [twitterFeed setDelegate:self]; twitterFeed is a UIWebView set to go to Twitter's mobile site, but that's beside the point. I'm getting the error "Sending 'SocialView (the name of the class that this is in) to parameter of incompatible type 'id'. I don't know how to fix it. Is there any way to do this quickly and without restructuring my code too much? Also, it is worth noting that SocialView is a UIViewController,

Error Compiling C++/CLI Delegate call using Predicate with Array::FindAll()

北城以北 提交于 2020-01-01 09:25:08
问题 The following code results in C3867 (...function call missing argument list...) and C3350 (...a delegate constructor expects 2 argument(s)...). What am I doing wrong? public ref class Form1 : public System::Windows::Forms::Form { public: bool IsEven(int i){ return (i % 2) == 0; } Form1(void) { numbers = gcnew array<int>{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; array<int> ^even = Array::FindAll( numbers, gcnew Predicate<int>(IsEven)); } }; 回答1: In C++/CLI you have to pass the actual instance of the

qml FolderListModel

♀尐吖头ヾ 提交于 2020-01-01 09:18:40
问题 I am trying to use FolderListModel, according to this example like this: ListView { anchors.fill: parent FolderListModel { id: foldermodel folder: "C:/Qt/Projects/" showDirs: true showDotAndDotDot: true nameFilters: ["*"] sortField : "Name" } Component { id: filedelegate Text { text: fileName } } model: foldermodel delegate: filedelegate } i want to show all the files/directories under the base directory, in a recursive way. does any one have an idea how to do that? 回答1: It seems that you

Delegates as parameters in VB.NET

梦想的初衷 提交于 2020-01-01 09:03:25
问题 Backstory: I'm using log4net to handle all logging for a project I'm working on. One particular method can be called under several different circumstances -- some that warrant the log messages to be errors and others that warrant the log messages to be warnings. So, as an example, how could I turn Public Sub CheckDifference(ByVal A As Integer, ByVal B As Integer) If (B - A) > 5 Then log.ErrorFormat("Difference ({0}) is outside of acceptable range.", (B - A)) End If End Sub Into something more

How to implement C++ style function pointers in C#?, Without using delegates

对着背影说爱祢 提交于 2020-01-01 05:47:12
问题 I am learning pointers in C# and was curious if one can use C++ style function pointers in C#. Yes, I know C# has its own equivalent concept for Function Pointers(called as delegates). But I just want to know if the same can be achieved using pointers in C#, without using delegates. If using pointers is completely legal in C#(using unsafe option) and pointer semantics is almost similar to C/C++ then in my opinion one should also be able to use C/C++ style function pointers as well. Please

Application Delegate - Cocoa

江枫思渺然 提交于 2020-01-01 05:47:07
问题 I want to incorporate an applicationDidFinishLaunching: into my cocoa delegate. How would I do this?? On the iphone SDK the applicationDidFinishLaunching is already in the application delegate, but when making my mac application I noticed that there were none. Best Regards, Kevin 回答1: As of Xcode 3.2, the Mac application template also comes with an application delegate, already connected, that has such a method. To set this up in a project created before Xcode 3.2, create a new class for your