FAQ Database Discussion Community


Swift: use of 'self' in method call before super.init initializes self compile error

ios,delegates,protocols
I made a custom class that handles audio recording/playback and put a Protocol in that class. I implemented the Protocol in a UIViewController class and called my setDelegate method for my AudioHelper class. I am getting a compile error that has to do with my init(). Not exactly sure how...

does not conform to protocol Swift Parent Class - Objective C Protocol

objective-c,swift,protocols
I am trying to call my Protocol Class in Swift, but its giving me Error "Type SwiftViewController does not conform to protocol ABCDelegate. Could you please tell me what I am missing , as I find other posts , but nothing is explained properly , also let me know if...

How to adhere to protocol method with a Raw type in method argument?

ios,swift,protocols
protocol Measurement { mutating func convert(#toUnit: String) } enum MassUnit : String { case Milligram = "mg" } enum VolumeUnit : String { case Milliliter = "ml" } struct Mass : Measurement { mutating func convert(#toUnit: MassUnit) // Build error: Does not adhere to 'Measurement' } struct Volume : Measurement...

Can both sides send data on an FTP bi-directional data connection

ftp,protocols,ftp-client,ftps
I always thought that when FTP data connection opens, it transfers data only in one way. Now I found out that both sides can transfer data on the opened data connection. My questions: What is it used for? I read that it can be used to transfer files over SSL,...

Own protocol in browser

c#,.net,browser,protocols,neodynamic
I try to implement WebClientPrinter by Neodynamic. This library makes request by this format: webclientprint:http://localhost:1294/wcp.axd?sid=cm50pdi0tyfsm0feejnzjtsk&wcppping it is similar to this notation. javascript: method() My question is why browser know what to do with this protocol?...

Swift - Passing an UIImage to an UIImageView via delegation

ios,swift,uiimageview,uiimage,protocols
I'm out of ideas and I have no idea how to solve this. Any help will be appreciated. I've got the following situation: MainViewController which points to a CollectionView embedded in a NavController CollectionView points to a DetailViewController DetailViewController shows the full picture chosen in the CollectionView and has a...

Swift equivalent of id?

objective-c,swift,delegates,protocols
The question is in the title. In Objective-C, if I want to have a property (like a delegate) that HAS to adhere to a certain protocol it can be defined like so: @property (weak) id<MyDelegate> delegate; How can I do this in Swift?...

What are the major differences between HTTP and COAP?

http,protocols,iot,coap
HTTP is mainly used for viewing web pages. Coap is a simplified version of HTTP for IoT or WSNs. Although COAP is based on UDP, it should have ACK messages to emulate TCP. Since COAP is simpler than HTTP, it will have lower latency and draw less power. Then, why...

OPC UA protocol vs MQTT protocol

protocols,communication,mqtt,opc,iot
I would like to compare OPC UA vs MQTT on basis of the general characteristics of both the protocols such as Overhead (Packets), Security, Information modeling and Reliability. Where can I find some sample data for Overhead, and other characteristics, for each protocol so that I compare them. I need...

how to declare a generate protocol as delegate?

swift,generics,protocols
we can make generate protocol like the follow: protocol SomeDelegate { typealias T func xxx(x: T) } and make some class conform it: class AA: SomeDelegate { typealias T = Int func xxx(x: T) { // do some thing } } and my problem was how to declare some propert...

python dpkt pcap how to get protocol?

protocols,pcap,dpkt
I have a lab and I need to find the protocol for each packet of a huge pcap file. I am going to make a dictionary to hold them all but my first step is just to pull the information using dpkt. It looks like ip.get_proto is what I want...

App compiles WITHOUT protocol functions - why?

ios,swift,protocols
Beginner with swift so please be gentle I'm playing around with the AppDelegate.swift file in the Master-Detail sample provided with XCode. The Appdelegate file has the first line class AppDelegate: UIResponder, UIApplicationDelegate { Which I understand to mean that AppDelegate is a sub-class of UIResponder and conforms to the UIApplicationDelegate...

How Do I retrieve a URL Protocol Request in C#

c#,wpf,protocols
I have a Windows WPF application running in the background at all times. I have registered a URL protocol in with the application called WTL:. The protocol works when the application is closed, but how do I respond to it when the application is open or running in the background?...

how to implement the aodv protocol in ns2

c++,protocols,ns2
this is some part of my file AODV.tcl example of AODV implementation in ns2 the problem that i need to use the aodv.c and aodv.h in this implementation i don't know how to do this ?? i need to use all the functions in aodv.c file and i don't know...

Is it possible to make two SOCKSv4a session connections over one TCP connection?

sockets,tcp,proxy,protocols,socks
I'm trying to create multiple tunnels out of a single TCP connection to a SOCKSv4a proxy server in order to keep from closing and reopening a bunch of sockets to the SOCKS proxy. Something like "Connection: keep-alive". How can I do that? Does the protocol allow it?...

Swift Syntax Update? Classes not allowed in protocol. Can't fill SKTexture

ios,swift,protocols,sktexture
I'm currently working on a tutorial for creating an iOS Isometric Game. You can find this one here. I just started coding Swift and because a lot of Syntax errors appeared while working with tutorials a little older than 3 months I asked my self if there were some main...

Unable to use custom class in a protocol with @objc attribute?

ios,objective-c,swift,delegates,protocols
I am trying to create a protocol for JSON loading delegation, JSONLoaderDelegate. My other class, called JSONLoader, is supposed to dispatch events to its delegate (that implements the JSONLoaderDelegate protocol) like: self?.delegate?.jsonLoaderdidEndWithError(self!, error: JSONLoaderError.LoadError) The implementation of the JSONLoader is not that important (imho). However I seem to have problems...

Swift: Check if class conforms to protocol for getter

ios,swift,generics,reflection,protocols
I was wondering if it is possible to check if a class conforms to a protocol in swift. I have an EntityObject class, which contains some basic functionality in Java I'd make it abstract but since swift doesn't do abstraction I'm running it like this. I also have an Entity...

Adding protocols for dynamically created UIPickerView

ios,objective-c,delegates,protocols,uipickerview
This question relates to this SO question (please see accepted answer). I'm adding a UIPickerView to a view which has not added the UIPickerViewDelegate or UIPickerViewDataSource protocols in its interface. However, all the required methods for the UIPickerView object has been properly implemented, and the program runs fine with these...

Understanding the Relation Between Delegation and Protocols

ios,objective-c,swift,delegates,protocols
I know there are a lot of similar questions here but I still need some clarification about this concept. First of all let me start by saying that I do understand what protocols are and how to use them, what I'm having problem understanding is delegation. I do understand that...

Console: How to check if a protocol is accessible

console,protocols
I am trying to find a method of checking if a protocol works on a computer. For example smtp/ftp. I guess I would have to check this somehow in console, right? My question is non-OS-specific, so I would like to know how to do it universally or in major systems...

Understanding the value of the header HTTP2-Settings used for http/2 requests and upgrade

http,protocols,spdy,http2
I'm writing a simple app to determine if certain websites support http/2. Based on what I've read in the draft: https://tools.ietf.org/html/draft-ietf-httpbis-http2-07#section-3.2 I should be able to do a get request such as GET / HTTP/1.1 Host: server.example.com Connection: Upgrade, HTTP2-Settings Upgrade: h2c HTTP2-Settings: <base64url encoding of HTTP/2 SETTINGS payload> and...

swift: delegate is nil after segue

delegates,protocols,segue,nil
I have a center ViewCentroller with a button to another ViewController. In the first file I also declare a protocol. This delegate works just fine in the first ViewCentroller, but after the segue has been performed, the delegate is nil. How can I solve this?

Google Protobufs in Java: How do you get a Message.Builder from a FieldDescriptor?

java,buffer,protocols,protocol-buffers
I have a FieldDescriptor for a message field defined in my protocol buffer. I want to start constructing a value for that field, but I'm stuck trying to get a Message.Builder for that FieldDescriptor. The code I'm writing is extremely generic - It's designed to serialize between MongoDB and Protocol...

Swift - how to declare a method which receives a number in a range

swift,generics,protocols,type-constraints
I want to create a function which has a number parameter that should be between 0..100 % I thought that the best way to enforce this would be by creating a wrapper type using FloatingPointType protocol , but I am getting a compilation error Protocol 'FloatingPointType' can only be used...

send class name as parameter in swift

swift,object,protocols
How can I send a class name as a parameter in swift? Here's what I'm trying to achieve: I have an object that I want it to take 2 different objects (object A, object B) as part of its initializers. Also, I need to be sure that both objects contain...

Swift Struct with Lazy, private property conforming to Protocol

swift,struct,protocols,lazy-evaluation
First, I have a protocol that defines only a few, readonly properties, ex: protocol Example { var var1:String { get } var varArray:[String] { get } } I then want to create a struct that conforms to that protocol. The problem I'm running into, is that I have two conflicting...

Purpose of Pseudo/Colon Header Fields

http,networking,http-headers,protocols,http2
As the title suggests, I'm looking for some information on the purpose of pseudo/colon header fields, i.e. I want to know why we have a second type of header field... Also - I know pseudo/colon header fields are used in http2 in place of the message and status lines (^^^the...

Using generic protocols in generic classes

class,generics,swift,constraints,protocols
I defined a protocol LLNodeType: protocol LLNodeType { typealias T var firstNode: LLNode<T>? { get } } LLNode<T> is just a simple generic class, which contains a stored property of type N. class LLNode<N> { var content: N ... } To conform to the LLNodeType protocol I therefore extended LLNode...

Specify a settable property/variable in a protocol

swift,protocols
I would like my protocol to declare that there is a read/write property available. I have attempted it, but this does not work: protocol EdibleThing { var eaten: Bool { get set } } class Pickle: EdibleThing { var eaten = false } class RusticGrapefruit: EdibleThing { var eaten =...

Charactersitics/features of communication (M2M)protocols for comparision

protocols,communication,m2m
What should be the characteristics/features of M2M protocols (MQTT/OPC UA/XMPP) for which the protocols can be compared? I would like to write an article about these protocols and would like to compare them on the basis of these characteristics. You can suggest some characteristics for M2M protocols comparison. such as:...

How to use delegates to communicate data from a custom cell to a label in the parent view

ios,uitableview,swift,delegates,protocols
I have figured out how to pass data between views with delegates in other situations but this one is stumping me. In this example I am trying to send data resulting from pressing a button, up to the label using a delegate pattern but without any success. My guess is...

FTP: How to direct the client to not modify the bytes it received?

sockets,ftp,client-server,protocols,ftp-client
I am trying to implement an FTP server in C. However, as I send bytes to the client, the client automatically modifies the bytes in a certain way. For example, I notice that the client changes 0D0A to 0A (CR+LF to LF). There are some other mysterious changes as well....

set NSArray protocol in swift

ios,objective-c,swift,nsarray,protocols
In Objective-C you can do something like NSArray<ReviewC>* reviews; in order to make a variable NSArray which follows the protocol ReviewC, I need to do the same in Swift, I need to make NSArray follow a protocol, it has to be An NSArray, not an Array. I know I can...

Delegate returning nil

xcode,swift,delegates,protocols
I'm trying to use a protocol / delegate in swift, and while I'm not getting any errors it seems that my delegate is not being created. Here is my code Class 1 import UIKit protocol GameViewSliding{ func slideGameView() } class GameDetailsViewController: UIViewController { var delegate:GameViewSliding? override func viewDidLoad() { super.viewDidLoad()...

How can I make my Objective-C class conform to Swift's `Equatable` protocol?

objective-c,swift,protocols,language-interoperability
I have an Objective-C class (that happens to be a button, but that is not important), and at another part of my (mixed language) project, I have an array of these buttons and I'd like to get the index of a button using the find() method. Like so: func doSomethingWithThisButtonIndex(index:Int)...

How can I call this generic function?

swift,generics,protocols,type-inference
I just thought of this trying to figure out Swift generics. I have come up with the following test code where I'd like to call f(). I can't figure out how I can tell the compiler that the T is Classy in this case. protocol Prot { func doSomething() static...

Add Subprotocol to websocket (c#, Universal App)

c#,websocket,protocols
I am trying to create a messagewebsocket with a specific sub-protocol. In javascript this wouldn't be a problem, but in c# there is no parameter for this. The only thing I've found is how to get a list of the protocols, (https://msdn.microsoft.com/en-us/library/windows/apps/windows.networking.sockets.messagewebsocketcontrol.supportedprotocols) but there is no setter.

What's the best protocol for live audio (radio) streaming for mobile and web?

audio,streaming,protocols,shoutcast,internet-radio
I am trying to build a website and mobile app (iOS, Android) for the internet radio station. Website users broadcast their music or radio and mobile users will just listen radio stations and chat with other listeners. I searched a week and make a prototype with Wowza engine (using HLS...

How to split up an array to specific size

c,protocols,wireless,tinyos,nesc
I am about to implement some algorithm in telosb motes. What I need to do is, take a file and split it up in smaller objects and then splitting up the object to even smaller object called pages, like described in the figure below. After doing that, the page will...

Nmap shows that port 5222 is closed but pidgin which uses xmpp(5222) is running. How is this possible?

security,protocols,nmap
I am learning to use Nmap. I set up pidgin which uses port 5222(xmpp) for chatting. But when I scan my ports, port 5222 is shown as closed. But chat is working. How is this possible?

Calling a Method on an Objective-C Delegate from Swift

ios,objective-c,swift,delegates,protocols
I'm writing some Swift classes that build upon functionality in our objective-c app. I have a objective-c class with a delegate that conforms to a protocol. I'm trying to call a method on that delegate from inside of a Swift class I'm simplified it down to this. FredTestProtocol.h: @protocol FredTestProtocol...

TCP Three way handshake - Piggybacking ACKs

networking,tcp,protocols,handshake
I understand that in the three-way handshake, sometimes the receiving end will send a SYNACK packet when establishing a connection (piggybacking), but when would it ever send a SYN and then an ACK packet? For example: ->SYN <-SYN_ACK ->ACK versus: ->SYN <-SYN ->SYN_ACK Thanks!...

Delegate method not being called or not firing when called

ios,objective-c,delegates,protocols
I'm trying to implement two delegate methods. I think I have the protocol written correctly, and that I'm assigning the delegate correctly, as I modeled it carefully on another delegate/protocol that works fine. However, the delegate methods don't fire when called, or at least that appears to be what's happening....

Swift: Protocol Based Type Construction

swift,protocols,object-construction
I'm trying to create a protocol in Swift I can use for object construction. The problem I'm running into is that I need to store the type information so the type can be constructed later and returned in a callback. I can't seem to find a way to store it...

Why XMPP RFC 3920 force the server-to-server communication using two separate TCP connection?

xmpp,protocols
In RFC 3920 (XMPP core), it define there must be one TCP connection for each direction for server-to-server communication, but for client-to-server it doesn't force it. So any reason or benefit to force two TCP connections for server-to-server? In the context of client-to-server communications, a server MUST allow a client...

protoc-c: Nested structure with optional string throws seg fault

c,serialization,deserialization,protocols,protocol-buffers
Trying out Google protocol buffers for my code in C language. messagefile.proto =================== mesage othermessage { optional string otherstring = 1; } message onemessage { optional string messagestring = 1; optional int32 aninteger = 2; optional othermessage otr_message= 3; } ============================================== --> protoc-c messagefile.proto --c_out=./ this resulted in two files...

How does an iBeacon/sender/receiver handle collisions?

protocols,collision,ibeacon
What is the theoretical/practical limit to the number of ibeacons you can have within their broadcasting range; there must be one. And what do they do, if anything to compensate should their signal constantly collide with another, unsure if they even know ? Anybody? Imagine you have 30 beacons within...

Why does the “request module” in Node.js accept only the URLs written with protocol?

node.js,http,get,protocols,node-modules
I want to send a GET request using request module. Here's the code: var requestModule = require('request'); var url = require('url'); var myUrl = 'www.google.com'; var myUrlObj = url.parse(myUrl); requestModule(myUrl, myUrlObj , callback); but it doesn't work because myUrlObj has a null value for its "protocol" attribute. The same code...

Objective C protocol method is not called

objective-c,singleton,protocols,avaudioplayer
I have created singleton class for AVAudioPlayer. I am able to call the methods in the class and everything works fine. When the song finishes,the method (void)audioPlayerDidFinishPlaying is called which in turn suppose to call the method ' processSuccessful' in my downloadPlay.m class. But, it is not calling the method...

How to express return type to be instance of a class which also confirms to a protocol in swift [duplicate]

ios,xcode,swift,protocols
This question already has an answer here: What is the equivalent of `UIViewController<MyProtocol>` of objc in swift? 1 answer I would like to define the return type of a function to be an instance of UIViewController which also conforms to a certain protocol (for example MyProtocol). How is it...

What is the proper way to declare a delegate variable?

cocoa,delegates,xcode6,protocols
In MyModel.h, I declared a delegate variable like this: @property(weak) IBOutlet id <MyProtocol> delegate; I've also seen a delegate variable declared like this: @property(weak) IBOutlet NSObject <MyProtocol>* delegate; I'm wondering which I should use. Also, Xcode 6.2 indicates I'm doing something wrong because when I connect the delegate outlet in...

Does X-Frame-options works for local files too?

html,file,http,protocols,x-frame-options
I load an html file ("file://...") in a web browser: in this file there's an <iframe>. Inside this iframe, I must load some remote content. I know the content I will load is protected by the X-Frame-Options HTTP response header, that can be used to indicate whether or not a...

How to convert/cast from a protocol to a class in swift?

ios,class,swift,protocols
Pretty simple, I'd have thought; I just want to check if a variable is a class and cast it to one if possible. For example: var cellProtocol:MyTableViewCellProtocol? = nil cellProtocol = tableView.dequeueReusableCellWithIdentifier(kCellIdentifier, forIndexPath: indexPath) as MyTableViewCell how do I explicitly cast the cell to a UITableViewCell? Inheritance as follows: class...

Swift Protocol get only settable?

ios,swift,protocols
why can I do this without any error: var testDto = ModelDto(modelId: 1) testDto.objectId = 2 while I define this: protocol DataTransferObject { var objectType: DtoType { get } var parentObjectId: Int { get set } var objectId: Int { get } var objectName: String { get set } }...

Implementing swift equatable protocol gives me bad access error. why?

ios,swift,compiler-errors,protocols
here is my code. it seems that when i subclass UIColor to make it equatable i get a memory error. why is that? class MyColor: UIColor, Equatable { var name: String init(name: String, r: CGFloat, g: CGFloat, b: CGFloat, a: CGFloat = 1.0) { self.name = name super.init(red: r, green:...

Setting the delegate from third to first viewController

ios,objective-c,delegates,protocols
I have three viewControllers. When I'm on the third view controller I want to send a message to the first one. I'm using a protocol and trying to set the delegate for this. viewControllerC.h @protocol ViewControllerCDelegate - (void)performAction; @end ... @property (nonatomic, strong) id<ViewControllerCDelegate> delegate; viewControllerA.h @interface ViewControllerA : UIViewController...

Communication frameworks summary [closed]

.net,wcf,protocols,communication
I'm a beginner in C# and .Net framework and I have been through the WCF chapter in my book. On the other hand it's still not clear what communication frameworks exist beside WCF. Does WCF cover everything? I tried to find a good website summarizing the protocols(both synchronous and asynchronous),...

basic TCP communication port related query

java,sockets,networking,tcp,protocols
Disclaimer : This question might seem stupid to people who understand how TCP works but I am at my wits end understanding this. All research on google feels like digging deeper into the hole i fell in and trying to get out Question ==> I have a gps device which...

Assigning a variable from another class

ios,objective-c,methods,protocols
I have a UIView with a UIButton created in 1 class: "viewClass". In my mainVC class, I called viewClas and I needed to call a method in mainVc when the button is selected, so I created a protocol. (I hope that was clear.) Here's how I set up the protocol...

Passing parameter to method which implements protocol and extends a class in swift

ios,templates,generics,swift,protocols
In Objective-C, you can inform the compiler that a type should be a descendent of a specific class, and also conform to a protocol (e.g. "UIViewController *foo = nil"). I'm trying to do something similar with Swift, and it looks like this requires use of generics. Here's what I would...

SagePay Upgrade 2.22 to 3.0 No Crypt Field

curl,aes,protocols,crypt,sagepay
I've been asked to assist upgrading a SagePay custom payment implementation from protocol v2.22 to protocol v3.0. I'm trying to follow the instructions on this page: https://www.sagepay.co.uk/support/12/36/upgrading-from-2-22-to-3-00-a-brief-overview The first problem I have is that nowhere in the existing code is there a 'Crypt' field. In fact the 'data' is sent...

What are protocols and delegates and how are they used in IOS? [duplicate]

ios,objective-c,delegates,protocols
This question already has an answer here: Protocols and Delegates for Dummies 4 answers I'm really confused about the concept of delegates and protocols. Are they equivalent of interfaces and adapter classes in Java? How do they work? None of the resources I've read were helpful so far. "Delegation...

Redirecting Ethernet traffic through another interface

routes,embedded,protocols,ethernet,dhcp
I'm working on a project where I want to redirect ethernet traffic through another interface. The setup is as follow: I have a computer with a working internet connection. I also have a MBED LPC1768 board which I can connect by USB with my computer. I can upload a binary...

Swift Dictionary with Protocol Type as Key

ios,osx,swift,dictionary,protocols
short question here: I got a protocol protocol SCResourceModel {..} and a dictionary which shall use this protocol type as key: [SCResourceModel : String]. This obviously does not work, as a key in a dictionary has to conform to the protocol Hashable. Making my SCResourceModel inherit from Hashable or trying...

Object initialization with protocol and class name in swift

objective-c,swift,initialization,protocols
In Ojective-C I wrote: id <MyProtocol> object = [[NSClassFromString(@"aClassName") alloc] initWithObject:obj]; I would like to write this in Swift. Is there to do the same or am I out of the language paradigm ? edit : Here's my context. Somewhere I have : - (instancetype)initWithObject:(NSArray *)array andClassName:(NSString *)className { self...

Swift Type “SceneName” does not conform to protocol ADInterstitialAdDelegate - SK Swift

swift,protocols
I cannotadd ADInterstitialAdDelegate to my class it says it does not conform to protocol... import SpriteKit import AVFoundation import iAd var classicHScore: AnyObject? = NSUserDefaults.standardUserDefaults().objectForKey("classicHighscore") var classicHScoreInt = classicHScore! as Int var interstitialAd = ADInterstitialAd() class SpeedGameScene: SKScene, SKPhysicsContactDelegate, ADBannerViewDelegate, ADInterstitialAdDelegate { No idea why i cannot find the answer...

What to use in replacement of an interface/protocol in python

python,interface,protocols
I am making a chess game and wanted to make a standard piece interface/protocol. Python does not have those in the language, so what am I supposed to use? I read a bit about factories, but I'm not sure how they would help. Thanks in advance!

iOS Swift - Protocol sending delegate to wrong TableViewController

ios,swift,delegates,protocols
I have an app with a chain of TableViewControllers, linked by a notification controller, retrieving information from a webservice. Data from the next table is pulled from an webservice, regarding the data chosen on the previous one. When I pull any table to refresh, it requests again the information a...

Why do we send the length of a string in most of the currently protocols

dns,protocols
I wondering why most of the protocols (Like dns for example) write the length of a string before it. For example: 3www6google3com Why did it do this in that way? I can't figure out through searches over the internet....

Should client protect himself from server bugs

architecture,protocols,server
I have a general question that related to architecture and protocols between clients and server. We have a large system that include server and many clients, that system synchronize files between client and server. In the server side we have allot of checks on the input from the client to...

Protocols and standards that take advantage of the huge IPv6 address space [closed]

networking,protocols,standards,ipv6
Unsure if this is the correct place for this kind of question (Server Fault is for administrators) but I'm looking for examples of (networking) protocols and standards that leverage the huge IPv6 address space towards some specific benefits. Reason is I'm writing a paper about something that does this and...

Protocol Inheritance in swift

ios,uitableview,swift,protocols
I am following this tutorial to perform TDD in swift. About halfway down, there is a point where we need to create a protocol that inherits from UITableViewController. Code looks like the following: import UIKit protocol MenuTableDataSource : UITableViewDataSource { func setMenuItems(menuItems: [MenuItem]) } We then create a class shortly...

How to call static method provided by protocol in Swift

ios,swift,static,protocols
How to access to static protocol method within a instance I have a list of Contact, the contact can be a FamilyContact that inherit from Contact and the GroupStatus protocol I want to call the static method from GroupStatus but in vain... Here is my code protocol GroupStatus { static...

Cannot conform to objective-c protocol in swift

ios,objective-c,swift,protocols
I'm trying to implement the awesome library JSQMessagesViewController but I keep getting the error "'ModelMessage' does not conform to protocol 'JSQMessageData'" even though my class inherit from NSObject and I implement the required properties Here is the protocol: @protocol JSQMessageData <NSObject> @required - (NSString *)senderId; - (NSString *)senderDisplayName; - (NSDate...

NSObject class conforms to protocol contained in NSArray with Swift

swift,nsarray,protocols,swift2,swift-array
I would like to create a method in Swift that returns an array of NSObject objects that conform to a protocol. I've tried something like this: func createManagers() -> [Manager] { let result = NSMutableArray(capacity: self.classes.count) (self.classes as NSArray).enumerateObjectsUsingBlock { (object: AnyObject!, idx: Int, stop: UnsafeMutablePointer<ObjCBool>) -> Void in //...

How does apple set the Delegates of the UIKit classes as Outlets?

delegates,uikit,protocols
I've been trying to find a way to set the delegates on my custom classes as Outlets so I can connect them via IB just like one does with an UIKit Class but I haven't been able to do this, is this even possible?

Implementation conflicts between protocols

swift,oop,inheritance,protocols,implementation
I've stumbled upon an issue, and I can not figure out how am I going to solve it. Let's suppose we have a base class (that may comes from FrameworkA), with a property named subject: public class MyClass { public var subject: String } And we have a protocol (that...

How to use PHP to recognising (and not validating) URL

php,url,protocols,strpos
I'm aware of filter_var() and it's FILTER_VALIDATE_URL filter. The point is there are some URLs which are exist but not count as a valid URL and I need to verify them. For example, URLs with spaces. At the moment I am checking only those protocols that application is interested in...

A Simple TCP Protocol to Transfer a “Large” Data File to a Server

sockets,tcp,protocols,network-protocols
MESSAGE TO DOWN VOTERS: Please read the question, I am working on a small embedded device. If you are not familar with the limitations of such a device, then please move onto another question instead of down voting!!!! I am working with a small embedded device that has limited memory...

Swift protocol that is using an enum with generic associated type

swift,generics,enums,protocols
I'm trying to create a protocol that is using a generic enum in swift. The compiler throws this error: Protocol can only be used as a generic constraint because it has associated type requirements Short code snipped: enum GenericEnum<T> { case Unassociated case Associated(T) } protocol AssociatedProtocol { typealias AssociatedType...

Use of TypeName in variable declaration in Objective-C

objective-c,protocols
Usually when it comes to declare a variable as a protocol it's done as follows: id<protocol_name> variable; But recently I've seen something that I don't fully understand. The compiler allows you to define things like: NSString<protocol_name> *variable; In fact assigning from other "plain" NSString variable will cause the compiler to...

Error correcting codes for packet loss (UDP)

c++,math,udp,protocols,error-correction
I have no real idea what to look for, since all I get with "Error correcting codes" is stuff related to cases where you don't know the location of the error. Thus those codes are much more complicated an inefficient than I need them to be. In the following, note...

How to reference a generic class with a constraint from a Protocol with a typealias in Swift?

swift,protocols,swift-generics
I'm try to define a protocol P2 so that it returns a generic class with a constraint on another protocol P1, e.g: protocol P1 {} class C<T : P1> {} public protocol P2 { typealias T class func c() -> C<T> } But this results in the following compiler error:...

Setting delegates (for protocols) only works in prepareForSegue?

ios,objective-c,delegates,protocols
Most of the information I found involving implementing protocols and delegates involves a step where you do this; DestinationViewController *destinationVC = [[destinationViewController alloc] init]; destinationVC.delegate = self; But after hours of frustration because I couldn't get it to work I finally stumbled across another way to allocate the destinationVC in...

Applying Generics to Variables and Functions - Swift

ios,generics,swift,protocols,nsobject
I'm trying to use generics in swift in order to initialise variables within my Vector3D class. However, upon assigning the protocol 'Number' to my variable (to make it either a Double or Float) I get the following error: Protocol 'Number' can only be used as a generic constraint because it...

Confused about layers of FIX Protocol

protocols,network-protocols,fix
What is the difference between the FIX Application Layer, FIX Presentation Layer, and FIX Session Layer?

Applications of microtransport protocol? [closed]

protocols
I want to know real time application of micro transport protocol in networks. What are exact applications of micro transport (µTP) protocol?

Satisfy Swift Protocol Methods with Closure Attributes?

swift,closures,protocols
I have a protocol with a method. I have thought that methods can be replaced with closures by the same name, but it doesn't seem to work: protocol Foo { func bar() // Type: Void -> Void } class X: Foo { func bar() { } } class Y: Foo...