2 // HMScreenshotInformation.swift
5 // Created by Hori,Masaki on 2014/12/23.
6 // Copyright (c) 2014年 Hori,Masaki. All rights reserved.
12 var formatter: NSDateFormatter?
14 class HMScreenshotInformation: NSObject
16 override class func initialize() {
17 formatter = NSDateFormatter()
18 formatter?.dateStyle = .ShortStyle
19 formatter?.timeStyle = .ShortStyle
20 formatter?.doesRelativeDateFormatting = true
23 init(path aPath: String) {
31 lazy var url: NSURL? = {
32 return NSURL.fileURLWithPath(self.path)
34 lazy var creationDate: NSDate? = {
35 let fm = NSFileManager.defaultManager()
36 let fileAttr: NSDictionary = fm.attributesOfItemAtPath(self.path, error: nil)!
37 return fileAttr.fileCreationDate()
40 var imageUID: String {
43 var imageRepresentationType: String = IKImageBrowserQuickLookPathRepresentationType
44 var imageRepresentation: AnyObject {
47 var imageTitle: String {
48 return path.lastPathComponent.stringByDeletingPathExtension
50 var imageSubtitle: String? {
51 if creationDate == nil {
54 return formatter!.stringFromDate(creationDate!)
56 var imageVersion: UInt {
65 var error: NSError? = nil
66 var resource: AnyObject? = nil
67 if !url!.getResourceValue(&resource, forKey: NSURLTagNamesKey, error: &error) {
69 println("get tags error -> \(error)")
73 return resource as? [String]
79 var error: NSError? = nil
80 url!.setResourceValue(newValue, forKey: NSURLTagNamesKey, error: &error)
82 println("set tags error -> \(error)")
87 override var hash: Int {
90 override func isEqual(object: AnyObject?) -> Bool {
91 if super.isEqual(object) { return true }
92 let info = object as? HMScreenshotInformation
93 if info == nil { return false }
94 return path.isEqual(object!.path)