protocols

Class Protocol: Cannot use mutating member on immutable value: 'self' is immutable

落花浮王杯 提交于 2019-12-12 04:54:20
问题 I have protocol from framework public protocol BaseMappable { /// This function is where all variable mappings should occur. It is executed by Mapper during the mapping (serialization and deserialization) process. mutating func mapping(map: Map) } and i have my protocol with extension (default implementation) public protocol DtoResponseRequestActionable: class { func transferToResponceAction(_ dto: TransferToResponce) } extension DtoResponseRequestActionable where Self: BaseMappable { func

How do you interpret this phrase?

我与影子孤独终老i 提交于 2019-12-12 04:27:40
问题 How do you interpret this phrase? Checksum This is the value to make zero on the addition of the lower 8 bits from the header to the checksum. With this protocol description: Protocol Consist of header (1 byte) + data length (1 byte) + command data (13 bytes) + check sum (1 bytes) + connection ID (1 byte). (I literally copied this protocol description, so I'dont know why there is 1 bytes (in plural). But I can tell you it is only one byte) Here are some sample TCP packets of this protocol: HE

Protocol and Delegate not working.. what did i do wrong?

自作多情 提交于 2019-12-12 04:18:19
问题 i am trying to send an image from my collectionViewCell imageView to an imageView in another VC through delegation and Protocol. I cannot figure out why this isn't working properly? The sending VC is: TrainersViewController The recieving VC is: BioViewController Here is my protocol: protocol TrainersViewControllerDelegate: class { func trainersViewController(controller: TrainersViewController, didFinishSendingImage trainer:TrainerArray) } class TrainersViewController: UIViewController,

how to solve “Protocol … can only be used as a generic constraint…”

[亡魂溺海] 提交于 2019-12-12 04:17:41
问题 Consider this fragment of code: public protocol Evaluable { typealias ReturnType func eval(s: State) -> ReturnType } protocol AlgebraicExpr : Evaluable { } public struct Const : AlgebraicExpr { var value: Int = 0 public func eval(s: State) -> Int { return value } } public struct Add : AlgebraicExpr { let a, b: AlgebraicExpr public func eval(s: State) -> Int { return a.eval() + b.eval() } } it is invalid because Add cannot have an AlgebraicExpr variable. But I really need Add to store two

Swift - Passing value back to ViewController using protocol and delegate

99封情书 提交于 2019-12-12 04:10:20
问题 I'm new to swift and my problem right now is I want to pass the value from RoutePreviewController page back to display on ViewController page after clicking on the Navigate Button. As below picture, you can see that the RoutePreviewController is not directly segue from the ViewController. This is my story board of the swift project on xcode However, I tried using protocol and delegate in the code. Here are codes that I have add to the ViewController (MainPage) protocol HandleSelectedPath{

Compilation error while adding mp-olsr on ns 2.34 (Jiazi YI ns 2.29)

痴心易碎 提交于 2019-12-12 03:53:22
问题 I'm trying to add the mp-olsr(ns 2.29) into ns 2.34 and I'm getting some errors while compiling it. Source code(Jiazi YI): http://www.jiaziyi.com/index.php/research-projects/mp-olsr Procedure: $ touch common/packet.cc $ make Result: mpolsr/MPOLSR.o: In function MPOLSR::MPOLSR(int)': MPOLSR.cc:(.text+0x1457): undefined reference to Agent::Agent(packet_t)' mpolsr/MPOLSR.o: In function MPOLSR::MPOLSR(int)': MPOLSR.cc:(.text+0x16f1): undefined reference to Agent::Agent(packet_t)' collect2: ld

How can swift closure reference properties of class its running from?

蓝咒 提交于 2019-12-12 03:47:28
问题 I have the following 2 controllers listed below. I'm using delegation to try and create a progressWindow which will run code and print it nicely but where the code is arbitrary. The closures are defined by the class conforming to the protocol (in my case SyncViewController), but I want to change the UI of the progressWindowViewController from SyncViewControllers codeToRun {} closure. How do I do this? SyncViewController.swift import UIKit class SyncViewController: UIViewController,

Swift: collectionviewHeader delegate not working?

。_饼干妹妹 提交于 2019-12-12 03:44:52
问题 Ok, Im still new with protocols but I need to call a function (that I know works when called in the header class) from another class. To do this, In the class from which Im calling the function (its a MSMessagesAppViewController) I have: public protocol MSMessagesAppViewControllerDelegate: class { func shrinkHeight(height:CGFloat) func growHeight(height: CGFloat) } weak var delegate: MSMessagesAppViewControllerDelegate? delegate?.shrinkHeight(height: 90) Then I have in class

How to make Hadoop servers listening on all IPs

↘锁芯ラ 提交于 2019-12-12 03:36:17
问题 I'm learning to deploy Hadoop Cluster on 2 machines, one master and one slave. However, after deployment the web app server(i.e. port 8088 on master) is not reachable. I use netstat -ant to check it says like below: proto Recv-Q Send-Q LocalAddress ForeignAddress State ... tcp 0 0 127.0.0.1:8088 *:* LISTEN tcp 0 0 0.0.0.0:56666 *:* LISTEN ... Other servers established by myself, like the one listening on port 56666 , are reachable. I think it maybe the problem that Hadoop web app server is

Swift: Adding parameter to protocol function

限于喜欢 提交于 2019-12-12 02:44:43
问题 Consider the following code, which prints "working" when a button is pressed: protocol MyClassDelegate: class { func foo() } class MyClass { weak var delegate: MyClassDelegate? func foo() { delegate?.foo() } let button: UIButton = { button.addTarget(self, action: #selector(foo), for: .touchUpInside) return button }() } class MyViewController { ... } extension MyViewController: MyClassDelegate { func foo() { print("working") } } When I try adding a parameter to MyClassDelegate 's foo method,