While watching session 408, about Protocol oriented programming, I kept asking myself why Dave appeared to leave the impression that POP is something different from OOP. Today I read a nice article about it, by Marcel Weiher, here.
[...] the idea was really to first get him all excited about not needing OOP, and then turn around and show him that all the things I had just shown him in fact were OOP. And still are, as a matter of fact. Always have been.
[...] The simple fact is that actual Object Oriented Programming is Protocol Oriented Programming, where Protocol means a set of messages that an object understands.
I think it's really worth the read.
I started doing it at some point, but never got through with it, but with the release of Swift 2.0, there's no better chance to try all the new things and come out with a better app as well. I will be writing my journey, which won't be too long, since the app is pretty simple, but I can see quite a few hurdles ahead.
I will prefix post titles with [EP] when writing about it. Stay tuned.
Super Fast Soft Shadow system for Unity:
We're the authors of Chipmunk2D physics engine and Cocos2D-SpriteBuilder maintainers. We recently rewrote the Cocos2D renderer and added lighting effects, and now we're back to writing Unity plugins!
[...]
Shadow mask generation occurs in a single pass - it doesn't use expensive image filters or pixel shaders to soften the shadows. This means it runs great on mobile!
[...]
Physically realistic penumbra, umbra, and antumbra rendering is based on configurable light sizes. This produces accurate rendering when the light source is larger than the objects casting the shadows.
Found this gem on Medium and bookmarked it. I think you should too.
I won't go into details, because others have already done that, and better than I would, so I will just share some links: Ash Furrow, Ray Wenderlich, The Next Web.
Also, Apple's Sample Code collection is pretty huge this year.
Here's a really small sneak peek by @AirspeedVelocity:
Woo,
finddid get a version that takes a closure (and got renamed toindexOf).
This makes usage of UIView.animateWithDuration:animations so much more appealing. Some examples from the repo's readme:
I already love Swift 2.0.
First, defer, to never forget to enableUpdates for the query:
query.disableUpdates()
defer { query.enableUpdates() }
// Do stuff.Secondly, for x in y where condition loops:
for iCloudEvent in document.data {
// I know, I know, worst sync ever; I will try to improve it at some point.
for localEvent in Events where localEvent.name == iCloudEvent.name {
// Update local events.
}
// Append to local events.
}Here is another nice read about protocols; method overriding, in particular. Some examples:
// Our generic class.
class DBStore<T> {
func store(a: T) {
store T
}
}
protocol Storeable { }
protocol Interim { }
// Hello, generic Method Overloading by Protocol:
class DBStore<T> {
func store<T: Storeable>(a: T) {
// Store T.
}
func store<T: Interim>(a: T) {
// Compress T.
}
// And more advanced:
func store<T: Storeable>(a: T) where T: Equatable {
// Store T.
}
}This is really, really awesome. Run your app and press the record button (next to the enable/disable breakpoints): as you navigate your app, code will be automatically generated. A quick test for LTHMonthYearPickerView:
let app = XCUIApplication()
let toolbar = app.toolbars
app.pickerWheels["2015, 46 of 91"].swipeUp()
toolbar.buttons["Done"].tap()
let textField = app.children(matching: .window)
.element(boundBy: 0)
.children(matching: .textField)
.element(boundBy: 0)
XCTAssertTrue(textField.value as? String == "June / 2034")
XCTAssertFalse(textField.value as? String == "June / 2033")The value property is, as described in the documentation:
The raw value attribute of the element. Depending on the element, the actual type can vary.First things first, I want to migrate old users' data to Swift objects:
// Didn't want to use CoreData just for one object, so I was creating an array of arrays:
// array[0] = recurring time, array[2] = name, etc.
// Don't laugh, it was a long time ago :)
unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData: dat];
kConstants.allTheData = [unarchiver decodeObjectForKey: @"dic"];
[unarchiver finishDecoding];to:
let unarchiver = NSKeyedUnarchiver(forReadingWithData: decryptedData)