//呼び出し元
@objc enum Status: Int {
case web
case normal
case none
func get1(str: String) -> Status {
switch str {
case "WEB会員":
return .web
case "ノーマル会員「":
return .normal
default:
return .none
}
}
}
class Enum {
func get() {
// 文字列取得
let sta = "WEB会員"
// 初期値取得
let status: Status = .none
// 文字列をもとに数字を取得今回は0
let i = status.get1(str: sta).rawValue
// dictに詰める
var dict: [String: Any]
dict = ["rank": i]
let a = Tamu()
a.consoleWrite(dict)
}
}
呼び出し先(objective-c側)
- (void)consoleWrite:(NSDictionary *)dict {
// integerValueで 型変換を行う。でないと正式にint型になってないから
NSInteger ka = [dict[@"rank"] integerValue];
if(StatusWeb == ka) {
NSLog(@"a");
}
}