Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Disk.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Disk"
s.version = "0.6.3"
s.version = "0.6.4"
s.summary = "Delightful framework for iOS to easily persist structs, images, and data"
s.description = <<-DESC
Easily work with the iOS file system without worrying about any of its intricacies. Save Codable structs, UIImage, [UIImage], Data, [Data] to Apple recommended locations on the user's disk. Retrieve an object from disk as the type you specify, without having to worry about conversion or casting. Append data to file locations without worrying about retrieval, manipulation, or conversion. Clear entire directories if you need to, check if an object exists on disk, and much more.
Expand All @@ -11,6 +11,9 @@ Pod::Spec.new do |s|
s.social_media_url = "https://twitter.com/sdrzn"
s.swift_version = "4.0", "4.2", "5.0"
s.platform = :ios, "9.0"
s.platform = :osx, "10.10"
s.platform = :tvos, "9.0"
s.platform = :watchos, "3.0"
s.source = { :git => "https://github.com/saoudrizwan/Disk.git", :tag => "#{s.version}" }
s.source_files = "Sources/**/*.{h,m,swift}"
end
24 changes: 21 additions & 3 deletions Disk.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
10F3C7041F23D9C9006D42EF /* Disk+Data.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10F3C7031F23D9C9006D42EF /* Disk+Data.swift */; };
10F3C7061F23D9E0006D42EF /* Disk+[Data].swift in Sources */ = {isa = PBXBuildFile; fileRef = 10F3C7051F23D9E0006D42EF /* Disk+[Data].swift */; };
10F3C7081F23DAF2006D42EF /* Message.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10F3C7071F23DAF2006D42EF /* Message.swift */; };
261E777E2178916800B7DFB6 /* DiskErrors.m in Sources */ = {isa = PBXBuildFile; fileRef = 261E777D2178916800B7DFB6 /* DiskErrors.m */; };
261E777F21789EB900B7DFB6 /* DiskErrors.h in Headers */ = {isa = PBXBuildFile; fileRef = 261E777C2178912C00B7DFB6 /* DiskErrors.h */; settings = {ATTRIBUTES = (Public, ); }; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -55,6 +57,8 @@
10F3C7031F23D9C9006D42EF /* Disk+Data.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Disk+Data.swift"; sourceTree = "<group>"; };
10F3C7051F23D9E0006D42EF /* Disk+[Data].swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Disk+[Data].swift"; sourceTree = "<group>"; };
10F3C7071F23DAF2006D42EF /* Message.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Message.swift; sourceTree = "<group>"; };
261E777C2178912C00B7DFB6 /* DiskErrors.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DiskErrors.h; sourceTree = "<group>"; };
261E777D2178916800B7DFB6 /* DiskErrors.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DiskErrors.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -103,6 +107,8 @@
103FA3761F713332004C600F /* Disk+InternalHelpers.swift */,
103FA3781F713340004C600F /* Disk+VolumeInformation.swift */,
104611771F27B27E00BBDB3A /* Disk+Errors.swift */,
261E777C2178912C00B7DFB6 /* DiskErrors.h */,
261E777D2178916800B7DFB6 /* DiskErrors.m */,
109256591F247F7700B3C32A /* Disk+Helpers.swift */,
10F3C6FD1F23D9A4006D42EF /* Disk+Codable.swift */,
10F3C6FF1F23D9B1006D42EF /* Disk+UIImage.swift */,
Expand Down Expand Up @@ -132,6 +138,7 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
261E777F21789EB900B7DFB6 /* DiskErrors.h in Headers */,
10F3C6F21F23D984006D42EF /* Disk.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -187,7 +194,7 @@
TargetAttributes = {
10F3C6E01F23D984006D42EF = {
CreatedOnToolsVersion = 9.0;
LastSwiftMigration = 0900;
LastSwiftMigration = 1010;
};
10F3C6E91F23D984006D42EF = {
CreatedOnToolsVersion = 9.0;
Expand Down Expand Up @@ -246,6 +253,7 @@
10F3C7041F23D9C9006D42EF /* Disk+Data.swift in Sources */,
103FA3791F713340004C600F /* Disk+VolumeInformation.swift in Sources */,
10F3C7001F23D9B1006D42EF /* Disk+UIImage.swift in Sources */,
261E777E2178916800B7DFB6 /* DiskErrors.m in Sources */,
104611781F27B27E00BBDB3A /* Disk+Errors.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -405,12 +413,17 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_BUNDLE_IDENTIFIER = saoudrizwan.Disk;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos watchsimulator appletvsimulator watchos appletvos macosx";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = "1,2,3,4";
TVOS_DEPLOYMENT_TARGET = 9.0;
WATCHOS_DEPLOYMENT_TARGET = 3.0;
};
name = Debug;
};
Expand All @@ -429,11 +442,16 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_BUNDLE_IDENTIFIER = saoudrizwan.Disk;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos watchsimulator appletvsimulator watchos appletvos macosx";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = "1,2,3,4";
TVOS_DEPLOYMENT_TARGET = 9.0;
WATCHOS_DEPLOYMENT_TARGET = 3.0;
};
name = Release;
};
Expand Down
8 changes: 8 additions & 0 deletions Disk.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
46 changes: 46 additions & 0 deletions DiskExample/Common/GetPosts.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// GetPosts.swift
// DiskExample
//
// Created by Craig Rouse on 29/05/2019.
// Copyright © 2019 Saoud Rizwan. All rights reserved.
//

import Foundation

func getPostsFromWeb(completion: (([Post]) -> Void)?) {
var urlComponents = URLComponents()
urlComponents.scheme = "https"
urlComponents.host = "jsonplaceholder.typicode.com"
urlComponents.path = "/posts"
let userIdItem = URLQueryItem(name: "userId", value: "1")
urlComponents.queryItems = [userIdItem]
guard let url = urlComponents.url else { fatalError("Could not create URL from components") }
var request = URLRequest(url: url)
request.httpMethod = "GET"
let config = URLSessionConfiguration.default
let session = URLSession(configuration: config)
let task = session.dataTask(with: request) { (data, response, error) in
DispatchQueue.main.async {
guard error == nil else { fatalError(error!.localizedDescription) }
guard let data = data else { fatalError("No data retrieved") }

// We could directly save this data to disk...
// try? Disk.save(data, to: .caches, as: "posts.json")

// ... and retrieve it later as [Post]...
// let posts = try? Disk.retrieve("posts.json", from: .caches, as: [Post].self)

// ... but that's not good practice! Our networking and persistence logic should be separate.
// Let's return the posts in our completion handler:
do {
let decoder = JSONDecoder()
let posts = try decoder.decode([Post].self, from: data)
completion?(posts)
} catch {
fatalError(error.localizedDescription)
}
}
}
task.resume()
}
File renamed without changes.
Loading