import android.app
import android.content
import android.os
import android.util
import android.view
import android.widget
struct pairstuff{
var a:String
var b:String
}
func testlet(_ arr:[pairstuff]){
if let elt = arr.first{
println("1st:\(elt.a)")
}
}
public class MainActivity: Activity {
public override func onCreate(_ savedInstanceState: Bundle!) {
super.onCreate(savedInstanceState)
ContentView = R.layout.main
let empty = [pairstuff]()
testlet(empty)
}
}
It gets compiled without errors and looks innocent enough, but it throws a null pointer exception at runtime.
Reason is, that the if let idiom doesn’t work as expected in this example.
Version info:
Microsoft Visual Studio 2015 Shell (Integrated)
Version 14.0.23107.0 D14REL
Microsoft .NET Framework
Version 4.6.00081
Installed Version: IDE Standard
RemObjects Elements 9.0.97.2071
RemObjects Elements (Oxygene, C# and Silver) for .NET, Cocoa and Java.
Copyright 2003-2016 RemObjects Software, LLC. All rights reserved. http://www.remobjects.com/elements
Interestingly, it now fails to build.
It would build the very first time,I tried after installation, but only that one time.
System restart Project clean up don’t seem to work.
It just says build failed, no Errors, no warnings:
It is even worse now: it won’t even build the unmodified android app template now, same behaviour.
version info:
Microsoft Visual Studio 2015 Shell (Integrated)
Version 14.0.23107.0 D14REL
Microsoft .NET Framework
Version 4.6.00081
Installed Version: IDE Standard
RemObjects Elements 9.1.100.2111
RemObjects Elements (Oxygene, C# and Silver) for .NET, Cocoa, Java and Island.
Copyright 2003-2017 RemObjects Software, LLC. All rights reserved. http://www.remobjects.com/elements
Apart from that, I found out, this happens, when using silver together with the Android sdk version that comes with “android-studio-bundle-162.3764568-windows.exe”, but
android-studio-bundle-145.3537739-windows.exe is ok.