Proper Swift type casting