-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added FileRepresentation class used for iCloud MetaData Queries
- Loading branch information
1 parent
946368d
commit 912647f
Showing
3 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+984 Bytes
(110%)
...roject.xcworkspace/xcuserdata/duncangroenewald.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
79 changes: 79 additions & 0 deletions
79
Sample Core Data App/Sample Core Data App/FileRepresentation.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// | ||
// FileRepresentation.swift | ||
// iWallet2 | ||
// | ||
// Created by Duncan Groenewald on 5/10/2014. | ||
// Copyright (c) 2014 Duncan Groenewald. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
@objc class FileRepresentation: NSObject { | ||
|
||
dynamic var filename: NSString? = nil | ||
dynamic var url: NSURL? = nil | ||
dynamic var fileDate: NSString? = nil | ||
dynamic var downloadStatus: NSString? = nil | ||
dynamic var nameOfSavingComputer: NSString? = nil | ||
dynamic var percentDownloaded: NSNumber? = nil | ||
dynamic var isDownloaded: NSNumber? = nil | ||
dynamic var isDownloading: NSNumber? = nil | ||
dynamic var ready: Bool = false | ||
|
||
init(filename: NSString, url: NSURL) { | ||
self.filename = filename | ||
self.url = url | ||
} | ||
init(filename: NSString, url: NSURL, date: NSString) { | ||
self.filename = filename | ||
self.url = url | ||
self.fileDate = date | ||
} | ||
init(filename: NSString, url: NSURL, percentDownloaded: NSNumber?) { | ||
self.filename = filename | ||
self.url = url | ||
self.percentDownloaded = percentDownloaded | ||
} | ||
init(filename: NSString, url: NSURL, percentDownloaded: NSNumber?, computer: NSString) { | ||
self.filename = filename | ||
self.url = url | ||
self.percentDownloaded = percentDownloaded | ||
self.nameOfSavingComputer = computer | ||
} | ||
func isEqualTo(object: FileRepresentation)->Bool | ||
{ | ||
if let filename = object.filename { | ||
return self.filename?.isEqualToString(filename as String) ?? false | ||
} else { | ||
return false | ||
} | ||
} | ||
var modifiedDate: NSString? { | ||
|
||
|
||
var filedate: AnyObject? = nil | ||
|
||
do { | ||
|
||
try self.url?.getResourceValue(&filedate, forKey:NSURLContentModificationDateKey) | ||
|
||
|
||
if let date = filedate as? NSDate { | ||
|
||
let dateFormatter: NSDateFormatter = NSDateFormatter() | ||
|
||
dateFormatter.dateStyle = NSDateFormatterStyle.MediumStyle | ||
|
||
dateFormatter.timeStyle = NSDateFormatterStyle.MediumStyle | ||
|
||
return dateFormatter.stringFromDate(date) | ||
} | ||
|
||
} catch { | ||
|
||
} | ||
|
||
return "" | ||
|
||
} | ||
} |