陈斌彬的技术博客

Stay foolish,stay hungry

初识 Swift Dictionary(原创)

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let keyString : NSString = "one two three four five"
        let keys : NSArray = keyString.componentsSeparatedByString(" ")


        let valuestring : NSString = "alpha bravo charlie delta echo"
        let values : NSArray = valuestring.componentsSeparatedByString(" ")


        let dict : NSDictionary = NSDictionary(objects: keys as [AnyObject], forKeys:values as! [NSCopying])


        NSLog("%@", dict.description)

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

img