@@ -25,7 +25,8 @@ import ImageIO
2525
2626 */
2727
28- class MyClass {
28+ public class MyClass {
29+ var name : String ?
2930 var timer : Timer ?
3031 func startTimer( ) {
3132 self . timer = Timer . scheduledTimer ( timeInterval: 1 ,
@@ -75,6 +76,9 @@ class ViewController: UIViewController {
7576 // overloading while hiding
7677 @nonobjc func dismissViewControllerAnimated( _ flag: Int , completion: ( ( ) -> Void ) ? ) { }
7778
79+ func testVisibility1( what: Int ) { }
80+ func testVisibility2( what: MyClass ) { }
81+
7882 override func viewDidLoad( ) {
7983 super. viewDidLoad ( )
8084
@@ -187,6 +191,30 @@ class ViewController: UIViewController {
187191 AudioServicesCreateSystemSoundID ( sndurl, & snd)
188192 }
189193
194+ do {
195+ class MyClass2 /*: NSObject*/ {
196+ var name : String ?
197+ }
198+ let c = MyClass2 ( )
199+ c. name = " cool "
200+ let arr = [ c]
201+ let arr2 = arr as NSArray
202+ let name = ( arr2 [ 0 ] as? MyClass2 ) ? . name
203+ print ( name)
204+ }
205+
206+ do {
207+ let lay = CALayer ( )
208+ class MyClass2 /*: NSObject*/ {
209+ var name : String ?
210+ }
211+ let c = MyClass2 ( )
212+ c. name = " cool "
213+ lay. setValue ( c, forKey: " c " )
214+ let name = ( lay. value ( forKey: " c " ) as? MyClass2 ) ? . name
215+ print ( name)
216+ }
217+
190218 do {
191219 let s = " hello "
192220 let s2 = s. replacingOccurrences ( of: " ell " , with: " ipp " )
@@ -306,7 +334,7 @@ class ViewController: UIViewController {
306334 func testDefault( _ what: Int = 42 ) { }
307335
308336
309- var myclass = MyClass ( )
337+ var myclass = MyClass ( ) // Objective-C can't see this
310338 func testTimer( ) {
311339 self . myclass. startTimer ( )
312340 }
0 commit comments