相关疑难解决方法(0)

有没有办法将Swift词典打印到控制台?

NSDictionary *dictionary = @{@"A" : @"alfa",
                             @"B" : @"bravo",
                             @"C" : @"charlie",
                             @"D" : @"delta",
                             @"E" : @"echo",
                             @"F" : @"foxtrot"};
NSLog(@"%@", dictionary.description);
Run Code Online (Sandbox Code Playgroud)

在控制台上打印出以下内容:

{
    A = alfa;
    B = bravo;
    C = charlie;
    D = delta;
    E = echo;
    F = foxtrot;
}
Run Code Online (Sandbox Code Playgroud)
let dictionary: [String : String] = ["A" : "alfa",
                                     "B" : "bravo",
                                     "C" : "charlie",
                                     "D" : "delta",
                                     "E" : "echo",
                                     "F" : "foxtrot"];
print(dictionary)
Run Code Online (Sandbox Code Playgroud)

在控制台上打印出以下内容:

["B": "bravo", "A": "alfa", "F": "foxtrot", "C": "charlie", "D": "delta", …
Run Code Online (Sandbox Code Playgroud)

xcode ios swift

73
推荐指数
9
解决办法
5万
查看次数

标签 统计

ios ×1

swift ×1

xcode ×1