Please help to remake this
if let field = parent_obj?.getFieldForCode(code) {
if let stored_value = field["value"] as? String {
into optional chaining syntax in single line. I tried to do it like this:
let stored_value = parent_obj?.getFieldForCode(code)?["value"] as? String
and got an error:
Type 'String' does not conform to protocol 'NSCopying'
This is my function header:
func getFieldForCode(code: String) -> NSDictionary?
Is it possible? I ask it because any time I work with NSArrays and NSDictionaries my code looks terrible:
if let code = self.row_info["code"] as? String {
if let value_field = self.row_info["value_field"] as? String {
if let field = parent_obj?.getFieldForCode(code) {
if let stored_value = field["value"] as? String {
if let fields = self.fields_set{
if let current_value = fields[indexPath.row][value_field] as? String {
Any advices?