Koichi Adachi

smart phone app development tips


Swift convert Dictionary<Int,AnyObject> to Dictionary<HogeType,AnyObject>

@objc public enum HogeType:Int{ case unknown case hoge1 case hoge2 case hoge3 case hoge4 case hoge5 } class A{ } bucket brigade let convertedDict = [1:A(), 2:A(), 100:A()].reduce([HogeType:A]()){ guard let controlType = HogeType(rawValue: …

pass a enum key Dictionary to Swift from ObjC

expect receive enum-key dict (Dictionary<EnumType,T>) from Objective-C. but can't receive direct EnumType key because XCode abandon generate method. ObjC's NSDictionary not allow Int for key. to use instead of NSNumber. definition in swift @objc publi</enumtype,t>…