jonasman / multicastdelegate Goto Github PK
View Code? Open in Web Editor NEWAn elegant multicast delegate written in swift
License: MIT License
An elegant multicast delegate written in swift
License: MIT License
Could you please consider adding Carthage support?
*** Skipped building MulticastDelegate due to the error:
Dependency "MulticastDelegate" has no shared framework schemes for any of the platforms: iOS
hi :)
It would be nice to maintain a Swift 3 compatible branch (i.e. compatible with the latest Xcode 8 beta).
I've got a fork here compatible with Xcode beta 4.
I can make a PR to a Swift 3 branch if you make one.
Best regards!
Hi João,
When updating my pods I received the following error:
" The platform of the target PROJECTNAME
(iOS 11.2) is not compatible with MulticastDelegateSwift (2.1.0)
, which does not support ios
"
I have attached my Podfile below:
platform :ios, '11.2'
target 'PROJECTNAME' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for PROJECTNAME
pod 'MulticastDelegateSwift'
end
I guess this is due to one of the latest commits (f601f7d):
- s.platform = :ios, '8.0'
- s.platform = :osx, '10.10'
+ s.ios.deployment_target = '8.0'
+ s.osx.deployment_target = '10.10'
Do I have to change anything in my Podfile ?
Thanks a lot for maintaining the MulticastDelegate project!
Best,
Andreas
As we can se in the issue #20, the delegates.count
property will count nil references, which would cause the following implementation to fail:
public var isEmpty: Bool {
return delegates.count == 0
}
To solve that:
public var isEmpty: Bool {
return delegates.allObjects.count == 0
}
This will only count existing objects, nil references won't be indexed in the allObjects
.
Example:
protocol ServiceDelegate { }
class Service {
var delegate = MulticastDelegate<ServiceDelegate>(strongReferences: true)
}
struct Struct: ServiceDelegate { }
let service = Service()
let x = Struct()
service.delegate.addDelegate(x)
service.delegate.removeDelegate(x)
// Not empty and you can't get the thing out ever again
Basically I'm wondering, why the generic type T
is not restricted to classes.
class ViewController: UIViewController, DemoServiceDelegate {
@IBOutlet weak var topLabel: UILabel!
@IBOutlet weak var bottomLabel: UILabel!
let dataService = DemoService.defaultService
override func viewDidLoad() {
super.viewDidLoad()
dataService.delegate += self
}
@IBAction func getDataTapped(_ sender: AnyObject) {
dataService.getData("TestingMulticast")
}
//MARK: DemoServiceDelegate
func gotYourData(_ value:String) {
topLabel.text = value
}
deinit {
dataService.delegate -= self
}
}
We need to remove delegate manually, In this example.
--
I've been using this library for a year or two on macOS by manually adding the source file. I'd like to use it with CocoaPods instead though (for automatic updates, etc).
If you're interested I can do a PR. I think the only requirement is adding an osx target to the .podspec. Would you also want a macOS specific demo?
Thanks for sharing this, it's worked perfectly for me!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.