protocols

Get value from Modal View in Swift iOS

痴心易碎 提交于 2019-12-11 09:53:28
问题 i'm trying to start writing Swift and i'm trying to get a value from a modal view controller with no luck. I have two controllers, the ViewController and modalViewController. In ViewController i have a UITableView and with a press of a button i open the modalViewController. Then from a UITextField i pass the value. I have implement a protocol with delegate and func but somewhere i'm missing something or had it wrong. ViewController.swift import UIKit class ViewController: UIViewController

applet alternative - Launch from browser

和自甴很熟 提交于 2019-12-11 08:56:55
问题 Recently I found an interesting Java applet which works pretty fine for electronic signature, but due to the recent NPAPI stuff with Chrome browser, I've considered it would be a good thing to migrate this applet to a Java application. HTML5/javascript/etc is not a possibility. The special requisite is that the application should be launched from a browser, despite not being an applet. The best approach I have found is as follows: Create an installer which would create a java executable file

How should the return value of JavaScript <href> links be handled?

纵然是瞬间 提交于 2019-12-11 08:18:28
问题 According to standards , what's the correct way to handle the return value of javascript protocol href links? Some examples: <a href='javascript:"Hello World";'> Click </a> <!-- return a String --> <a href='javascript:ThisFunctionReturnsString();'> Click </a> <a href='javascript:12345;'> Click </a> <!-- Number --> <a href='javascript:[1, 2, 3, 4, 5];'> Click </a> <!-- Array --> <a href='null;'> Click </a> <!-- null--> <a href='undefined;'> Click </a> <!-- undefined--> <a href='javascript:{};'

What is the expected behavior of a URL preceded with “//” when not linked from an existing page?

戏子无情 提交于 2019-12-11 08:08:32
问题 A nice trick to avoid insecure content warnings on pages that could be either http or https is to reference all scripts or assets in the code using "//" which will use the current page protocol instead of a specified one. If one enters a URL with // in the front directly into a browser URL box, is there a default behavior the browser will pick? Would/should it default to http or https , or some set of rules to test and pick one over the other? 回答1: A network-path reference (e.g., //example

Dictionary of a protocol Swift 4

眉间皱痕 提交于 2019-12-11 07:25:00
问题 I have a protocol called playable which requires implementation of func play() . Class Damage and DrawACard both conform to the protocol protocol Playable: class { func play(game: Game, value: Int) -> Player } class Damage: Playable, Hashable, Equatable { var hashValue: Int = 1 static func ==(lhs: Damage, rhs: Damage) -> Bool { return lhs.hashValue == rhs.hashValue } func play(game: Game, value: Int) -> Player { // do stuff return game.activePlayer } } class DrawACard: Playable, Equatable,

Swift - Error passing data between protocols / delegates (found nil)

白昼怎懂夜的黑 提交于 2019-12-11 07:15:18
问题 I am developing an application with swift 3.0. Where what I want to do is, from the "MainMapVC" class, which is the view where you have a map with a date slider (see the attached image). I want to move the slider and send that slider position (1,2 or 3) to LeftSideViewController which is the side view (the legend) updating the content depending on the selected date. View of MainMapVC: View of MainMapVC with Legend: Well, and I've come to the point where I have to pass a value between the two

Why does the following protocol have this required function?

淺唱寂寞╮ 提交于 2019-12-11 06:56:32
问题 The following code was mentioned at WWDC 2015: protocol Drawable { func isEqualTo(other: Drawable) -> Bool func draw() } extension Drawable where Self : Equatable { func isEqualTo(other: Drawable) -> Bool { if let o = other as? Self { return self == o } return false } } I'm a little confused on this whole protocol extension thing. Why would they have isEqualTo(other: Drawable) -> Bool in the Drawable protocol and then only extend when self is equatable? Why should isEqualTo be a required

Is it true Xcode/IB DOES NOT check for protocols?

一曲冷凌霜 提交于 2019-12-11 06:55:52
问题 Xcode5 milieu only. (Not older versions.) 1) make a new class called say Test. it's a UIViewController @interface Test:UIViewController 2) in storyboard, make a new screen, a UIViewController, change it to "Test" obviously, if you add a control (say, a button) on the storyboard, you can drag it to an IBOutlet defined in Test.h. No problem. 3) Now in Test.h add the two protocols .. @interface Test:UIViewController < UICollectionViewDataSource, UICollectionViewDelegateFlowLayout > 4) now in IB

XCode says 'Use of undeclared type' when trying to use a protocol defined inside a private Pod (Swift)

自作多情 提交于 2019-12-11 06:40:02
问题 I and my team are stuck in a strange situation involving a base project + private pods with some protocols inside. Our problem is we can't access some of the (protocol) identifiers (defined in a private pod) from our base app code. Apparently our problem seems to be exactly the same as the one described in these 2 stack overflow threads, but their solutions haven't worked with us. Thread 1: Source files not found in Swift Thread 2: CocoaPod installed but doesn't see Swift code The skeleton we

Protocol methods in a class extension are not called under specific conditions

六月ゝ 毕业季﹏ 提交于 2019-12-11 06:24:27
问题 I encountered a weird behavior. The best way I can put it is … Not overridden protocol methods in a class extension are not called while the superclass already conforms to the protocol (via extension) . However this happens only while it's build with the release build configuration. class A: UIViewController {} extension A: UIScrollViewDelegate { func scrollViewDidScroll(_ scrollView: UIScrollView) { print("scrollViewDidScroll in superclass") } } class B: A { // A tableView (and its data