0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

メモ

Posted at
//呼び出し元
@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");
    }
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?