I went astray, apparently due to two bugs with Swift generics in iOS 7. Here's how to fix them.
Mistake # 1 - you must define a shared object as the first property in your class before any others.
Example - this code does not work:
public class TestIOS7<T> { private var x: Int? } let x = TestIOS7<String>()
But here is a workaround:
public class TestIOS7<T> { private var kludge: T? private var x: Int? } let x = TestIOS7<String>()
Mistake # 2: Class restrictions seem to be completely broken.
Example - this code does not work:
class ClassA<B: ClassB> { } class ClassB { } let x = ClassA <String>()
I did not find a workaround other than removing the "ClassB" restriction and rewriting all the code to deal with the fact that basically this language feature no longer exists. This is especially painful when you need to call the ClassB initializer from ClassA - I had to rewrite this block with hardwired if / then / else for all my ClassB subclasses until Apple fixes it.
If someone finds a workaround for Bug # 2, please let me know!
alpsystems.com
source share