delegates

Why don't we instantiate delegating classes with their delegate objects?

只愿长相守 提交于 2019-12-13 16:29:17
问题 I can't imagine a delegating downloader class or CLLLocationManager or tableView be without a delegate. So why do we need create it as an optional? Why do we do tableview = UITableView() tableview.delegate = self tableview.dataSource = self Why isn't the API made so we could just do: tableview = UITableView(delegate: self, dataSource: self) Is this because memory cycles, so we could first nil either the delegating class or the delegate class and then the other? Is that the only reason? Even

C# version of Java Runnable? (delegate?)

时间秒杀一切 提交于 2019-12-13 15:24:33
问题 I could not find a direct answer to this question yet in SO. Is there a predefined delegate with void (void) signature? 回答1: Action has the signature you're looking for. However, it doesn't mean the same thing as Runnable does: Runnable generally indicates that the run() method is intended to be run on a Thread, while Action makes no indication. For that you'd want ThreadStart, which has the same signature, and does make that indication. If all you need is a delegate with no parameters,

iOS- protocols and delegates on the example

做~自己de王妃 提交于 2019-12-13 15:06:16
问题 Ok, i was searching but there wasn't any method that was working for me. Following code bases on many tutorials and Apple documentation, but i can't get it to work. Can anybody help please? Code is crashing at: obj.delegatee = self; (in class B.h), also methods respondsToSelector and performSelector:withObject aren't recogized. I want to set delegate object, on which there will be a method called when we tap on particular picture. class A.h: @interface AViewController : UIViewController

Obj-C header file not recognizing protocol from Swift class

谁说胖子不能爱 提交于 2019-12-13 14:14:18
问题 I've defined a protocol in a Swift file that isn't being recognized by an Obj-C header file. MainViewController.h #import "AppDelegate.h" @interface MainViewController : UIViewController <UICollectionViewDataSource, UICollectionViewDelegate, AnotherViewControllerDelegate> @end In th file above, I'm getting the following error: Cannot find protocol declaration for "AnotherViewControllerDelegate"; did you mean "UIPageViewControllerDelegate"? MainViewController.m #import "MainViewController.h"

Identifying different pickers in UIImagePickerController delegate

对着背影说爱祢 提交于 2019-12-13 12:17:38
问题 I have a view with a couple of buttons whick I use to present UIImagePickerControllers (both camera and media pickers). When I create the UIImagePickerControllers, I give them diffrent names and present them modaly as you can see in the code below: - (void) startMediaBrowserFromViewControllerForBGImage { UIImagePickerController * mediaUIForBGImage = [[UIImagePickerController alloc]init]; //i also set a bunch of different settings here, but it doesn't matter for this purpose mediaUIForBGImage

how delegates works and delegates work flow in objective-c

穿精又带淫゛_ 提交于 2019-12-13 10:54:02
问题 i am novice in Objective-c . i am learning objective-c . would you kindly let me know how this code work as well as would you kindly help to understand delegates work flow in objective-c SampleProtocol.h #import <Foundation/Foundation.h> @protocol SampleProtocolDelegate <NSObject> @required - (void) processCompleted; @end @interface SampleProtocol : NSObject { id <SampleProtocolDelegate> _delegate; } @property (nonatomic,strong) id delegate; -(void)startSampleProcess; @end after i added in

iOS SimplePing delegates

有些话、适合烂在心里 提交于 2019-12-13 09:54:23
问题 I am using SimplePing to scan my LAN. I am trying to ping all the availables IPs on my network so I am firing the ping fore the first host and then the delegates are firing the ping again for the next host. The issue here is that when a host is unreachable no delegate is firing. I am using the following delegates: - (void)simplePing:(SimplePing *)pinger didStartWithAddress:(NSData *)address; - (void)simplePing:(SimplePing *)pinger didFailWithError:(NSError *)error; - (void)simplePing:

Refactoring UITableView delegates for iOS7 and iOS8

家住魔仙堡 提交于 2019-12-13 09:49:40
问题 As a follow up to this question: Skip/ignore method in iOS, I'm trying to implement separate delegates for my UITableView in iOS7 and iOS8. So, as a first step, in viewDidLoad of my MyTableViewController , I added the following code: if ([[[UIDevice currentDevice] systemVersion] compare: @"8.0" options: NSNumericSearch] != NSOrderedAscending) { [self.tableView setDelegate: [[MyTVDelegate alloc] initWithIdentifier: myTVCellIdentifier]]; } else { [self.tableView setDelegate: [[MyTVDelegate7

MatchEvaluator gives “Cannot use a lambda expression…” error

喜你入骨 提交于 2019-12-13 09:15:18
问题 I'm modifying the contents of several files. I have this Regex in a form and it's called directly from a button's click event. public partial class MainForm : Form { private void UpdateButton_Click(object sender, EventArgs e) { // code if (!OldURLBox.Text.IsEmpty() && !NewURLBox.Text.IsEmpty()) { Regex patternURL = new Regex(string.Format("s:\\d+:\\\\\"((.(?!s:\\d+))*?){0}(.*?)\\\\\";", OldURL)); content = patternURL.Replace(content, delegate(Match m) // works fine { var prefix = m.Groups[1]

How to write read-only accessor functions in an aggregate root class?

ぐ巨炮叔叔 提交于 2019-12-13 07:19:37
问题 Overall design : I have an aggregate class C that contains N member variables of type M_i, i = 1 ... N that each have a common write-only update() interface as well as class-specific read-only accessor functions [F]un_i(), [F] = any letter, i = 1 .. N (they do not have such regular names in reality). Each of the member types M_i forms an independent abstraction of its own, and is used elsewhere in my program. The aggregate class needs to update all the members in a single transaction, so it