iosLearner iosLearner - 4 months ago 19
iOS Question

How to convert this code from Swift to objective - c?

var plays: [Int: Int] = [:]


var gridToPlace = 0
plays[gridToPlace] = plays[gridToPlace] != 0 ? 1 : 0
if plays[gridToPlace] == 1 { }


Can anyone help me to write this code in Objective C ?

if let _ = currentMove

Answer
NSMutableDictionary *plays = [[NSMutableDictionary alloc] init];

int gridToPlace = 0;

[plays setObject:(([plays objectForKey:@(gridToPlace)]) ? @(1) : @(0)) forKey:@(gridToPlace)];

if ([[plays objectForKey:@(gridToPlace)] integerValue] == 1) {

}
Comments