Skip to content

Commit

Permalink
Added FileRepresentation class used for iCloud MetaData Queries
Browse files Browse the repository at this point in the history
  • Loading branch information
duncangroenewald committed Sep 9, 2015
1 parent 946368d commit 912647f
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
A4A2F3BA1B9FA5B200B0A087 /* Sample_Core_Data_AppTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4A2F3B91B9FA5B200B0A087 /* Sample_Core_Data_AppTests.swift */; };
A4A2F3C51B9FA5B200B0A087 /* Sample_Core_Data_AppUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4A2F3C41B9FA5B200B0A087 /* Sample_Core_Data_AppUITests.swift */; };
A4A2F3D41B9FA6D900B0A087 /* CoreDataStackManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4A2F3D31B9FA6D900B0A087 /* CoreDataStackManager.swift */; settings = {ASSET_TAGS = (); }; };
A4A2F3D61B9FA83100B0A087 /* FileRepresentation.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4A2F3D51B9FA83100B0A087 /* FileRepresentation.swift */; settings = {ASSET_TAGS = (); }; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -54,6 +55,7 @@
A4A2F3C61B9FA5B200B0A087 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
A4A2F3D21B9FA67D00B0A087 /* Sample Core Data App.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = "Sample Core Data App.entitlements"; sourceTree = "<group>"; };
A4A2F3D31B9FA6D900B0A087 /* CoreDataStackManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoreDataStackManager.swift; sourceTree = "<group>"; };
A4A2F3D51B9FA83100B0A087 /* FileRepresentation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FileRepresentation.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -104,6 +106,7 @@
A4A2F39E1B9FA5B100B0A087 /* Sample Core Data App */ = {
isa = PBXGroup;
children = (
A4A2F3D51B9FA83100B0A087 /* FileRepresentation.swift */,
A4A2F3D31B9FA6D900B0A087 /* CoreDataStackManager.swift */,
A4A2F3D21B9FA67D00B0A087 /* Sample Core Data App.entitlements */,
A4A2F39F1B9FA5B200B0A087 /* AppDelegate.swift */,
Expand Down Expand Up @@ -275,6 +278,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
A4A2F3D61B9FA83100B0A087 /* FileRepresentation.swift in Sources */,
A4A2F3A31B9FA5B200B0A087 /* Sample_Core_Data_App.xcdatamodeld in Sources */,
A4A2F3A01B9FA5B200B0A087 /* AppDelegate.swift in Sources */,
A4A2F3A51B9FA5B200B0A087 /* MasterViewController.swift in Sources */,
Expand Down
Binary file not shown.
79 changes: 79 additions & 0 deletions Sample Core Data App/Sample Core Data App/FileRepresentation.swift
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 ""

}
}

0 comments on commit 912647f

Please sign in to comment.