Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

Commit

Permalink
Closes #50 by adding a sample for the image cache and replacing the S…
Browse files Browse the repository at this point in the history
…imple Cache sample with a Data Cache sample
  • Loading branch information
vittoriom committed Aug 12, 2015
1 parent c759ad8 commit 111e92d
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 11 deletions.
12 changes: 8 additions & 4 deletions Carlos.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
520863741B64268000F740C7 /* ExamplesListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5208636B1B64268000F740C7 /* ExamplesListViewController.swift */; };
520863751B64268000F740C7 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5208636C1B64268000F740C7 /* Images.xcassets */; };
520863761B64268000F740C7 /* MemoryWarningSampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5208636D1B64268000F740C7 /* MemoryWarningSampleViewController.swift */; };
520863771B64268000F740C7 /* SimpleCacheSampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5208636E1B64268000F740C7 /* SimpleCacheSampleViewController.swift */; };
520863771B64268000F740C7 /* DataCacheSampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5208636E1B64268000F740C7 /* DataCacheSampleViewController.swift */; };
520863791B64268700F740C7 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 520863781B64268700F740C7 /* Info.plist */; };
5208637E1B64268E00F740C7 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5208637A1B64268E00F740C7 /* LaunchScreen.xib */; };
5208637F1B64268E00F740C7 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5208637C1B64268E00F740C7 /* Main.storyboard */; };
520863811B642D4A00F740C7 /* PooledCacheSampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 520863801B642D4A00F740C7 /* PooledCacheSampleViewController.swift */; };
520863831B6430C600F740C7 /* CappedRequestCacheSampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 520863821B6430C600F740C7 /* CappedRequestCacheSampleViewController.swift */; };
520863851B64314400F740C7 /* DelayedNetworkFetcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 520863841B64314400F740C7 /* DelayedNetworkFetcher.swift */; };
522A4E6B1B7BDACB00646D52 /* ImageCacheSampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 522A4E6A1B7BDACB00646D52 /* ImageCacheSampleViewController.swift */; };
523257D21B51993000A10A56 /* TwoWayTransformationBoxTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 523257D11B51993000A10A56 /* TwoWayTransformationBoxTests.swift */; };
523257D41B519AB900A10A56 /* OneWayTransformationBoxTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 523257D31B519AB900A10A56 /* OneWayTransformationBoxTests.swift */; };
5243C4B31B77670F00737B3B /* StringConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5243C4B21B77670F00737B3B /* StringConvertible.swift */; };
Expand Down Expand Up @@ -191,13 +192,14 @@
5208636B1B64268000F740C7 /* ExamplesListViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExamplesListViewController.swift; sourceTree = "<group>"; };
5208636C1B64268000F740C7 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
5208636D1B64268000F740C7 /* MemoryWarningSampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MemoryWarningSampleViewController.swift; sourceTree = "<group>"; };
5208636E1B64268000F740C7 /* SimpleCacheSampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SimpleCacheSampleViewController.swift; sourceTree = "<group>"; };
5208636E1B64268000F740C7 /* DataCacheSampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DataCacheSampleViewController.swift; sourceTree = "<group>"; };
520863781B64268700F740C7 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
5208637B1B64268E00F740C7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = "<group>"; };
5208637D1B64268E00F740C7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
520863801B642D4A00F740C7 /* PooledCacheSampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PooledCacheSampleViewController.swift; sourceTree = "<group>"; };
520863821B6430C600F740C7 /* CappedRequestCacheSampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CappedRequestCacheSampleViewController.swift; sourceTree = "<group>"; };
520863841B64314400F740C7 /* DelayedNetworkFetcher.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DelayedNetworkFetcher.swift; sourceTree = "<group>"; };
522A4E6A1B7BDACB00646D52 /* ImageCacheSampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageCacheSampleViewController.swift; sourceTree = "<group>"; };
523257D11B51993000A10A56 /* TwoWayTransformationBoxTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TwoWayTransformationBoxTests.swift; sourceTree = "<group>"; };
523257D31B519AB900A10A56 /* OneWayTransformationBoxTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OneWayTransformationBoxTests.swift; sourceTree = "<group>"; };
5243C4B21B77670F00737B3B /* StringConvertible.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StringConvertible.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -424,12 +426,13 @@
5208636B1B64268000F740C7 /* ExamplesListViewController.swift */,
5208636C1B64268000F740C7 /* Images.xcassets */,
5208636D1B64268000F740C7 /* MemoryWarningSampleViewController.swift */,
5208636E1B64268000F740C7 /* SimpleCacheSampleViewController.swift */,
5208636E1B64268000F740C7 /* DataCacheSampleViewController.swift */,
AD695CE21B46CD65004E998D /* Supporting Files */,
520863801B642D4A00F740C7 /* PooledCacheSampleViewController.swift */,
520863821B6430C600F740C7 /* CappedRequestCacheSampleViewController.swift */,
520863841B64314400F740C7 /* DelayedNetworkFetcher.swift */,
528FAD471B7B0DCB0020A70E /* SwitchCacheSampleViewController.swift */,
522A4E6A1B7BDACB00646D52 /* ImageCacheSampleViewController.swift */,
);
path = Sample;
sourceTree = SOURCE_ROOT;
Expand Down Expand Up @@ -766,14 +769,15 @@
520863701B64268000F740C7 /* BaseCacheViewController.swift in Sources */,
520863851B64314400F740C7 /* DelayedNetworkFetcher.swift in Sources */,
528FAD481B7B0DCB0020A70E /* SwitchCacheSampleViewController.swift in Sources */,
522A4E6B1B7BDACB00646D52 /* ImageCacheSampleViewController.swift in Sources */,
5208636F1B64268000F740C7 /* AppDelegate.swift in Sources */,
520863721B64268000F740C7 /* ConditionedCacheSampleViewController.swift in Sources */,
520863831B6430C600F740C7 /* CappedRequestCacheSampleViewController.swift in Sources */,
520863741B64268000F740C7 /* ExamplesListViewController.swift in Sources */,
520863711B64268000F740C7 /* ComplexCacheSampleViewController.swift in Sources */,
520863811B642D4A00F740C7 /* PooledCacheSampleViewController.swift in Sources */,
520863761B64268000F740C7 /* MemoryWarningSampleViewController.swift in Sources */,
520863771B64268000F740C7 /* SimpleCacheSampleViewController.swift in Sources */,
520863771B64268000F740C7 /* DataCacheSampleViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
94 changes: 91 additions & 3 deletions Sample/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,107 @@
<simulatedStatusBarMetrics key="simulatedStatusBarMetrics"/>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" translucent="NO" prompted="NO"/>
<connections>
<segue destination="pIu-kR-eaS" kind="show" identifier="simpleCache" id="5dU-FT-vcl"/>
<segue destination="pIu-kR-eaS" kind="show" identifier="dataCache" id="5dU-FT-vcl"/>
<segue destination="cPe-S0-2ZW" kind="show" identifier="memoryWarning" id="Q7g-M3-nP3"/>
<segue destination="gIf-ro-V0s" kind="show" identifier="complexCache" id="ToB-8w-NSa"/>
<segue destination="jL4-x1-bK7" kind="show" identifier="conditionedCache" id="QWJ-yc-wQc"/>
<segue destination="U7q-Zo-Ph8" kind="show" identifier="pooledCache" id="g0G-lb-If9"/>
<segue destination="ev2-68-d1a" kind="show" identifier="cappedCache" id="lqm-hG-vhE"/>
<segue destination="iWa-HA-Zrq" kind="show" identifier="switchedCache" id="IYh-wq-B4X"/>
<segue destination="z71-b5-B3c" kind="show" identifier="imageCache" id="kMG-uK-xOr"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1198" y="325"/>
</scene>
<!--Image Cache Sample View Controller-->
<scene sceneID="KsD-v5-8ez">
<objects>
<viewController id="z71-b5-B3c" customClass="ImageCacheSampleViewController" customModule="CarlosSample" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="bVP-jU-SZv"/>
<viewControllerLayoutGuide type="bottom" id="e2Y-kR-dhP"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="c7c-tA-4hz">
<rect key="frame" x="0.0" y="0.0" width="600" height="536"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="URL" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="8d0-nd-unO">
<rect key="frame" x="15" y="20" width="34" height="20.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" horizontalHuggingPriority="249" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="kqz-lq-vil">
<rect key="frame" x="57" y="15" width="488" height="30"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="NRu-bS-Gfr"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
<connections>
<outlet property="delegate" destination="z71-b5-B3c" id="FrK-U3-9tb"/>
</connections>
</textField>
<button opaque="NO" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Ha3-ef-VDs">
<rect key="frame" x="555" y="15" width="30" height="30"/>
<state key="normal" title="GET">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="fetchButtonTapped:" destination="z71-b5-B3c" eventType="touchUpInside" id="fU3-3B-KLQ"/>
</connections>
</button>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" editable="NO" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7MY-j6-7cP">
<rect key="frame" x="15" y="55" width="570" height="100"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="100" id="VZI-tG-KOG"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
<dataDetectorType key="dataDetectorTypes" link="YES"/>
</textView>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="nBE-fh-KJY">
<rect key="frame" x="15" y="165.5" width="570" height="350.5"/>
</imageView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="kqz-lq-vil" firstAttribute="leading" secondItem="8d0-nd-unO" secondAttribute="trailing" constant="8" id="Bo5-KS-MJU"/>
<constraint firstAttribute="trailing" secondItem="7MY-j6-7cP" secondAttribute="trailing" constant="15" id="FC7-qJ-h1q"/>
<constraint firstItem="7MY-j6-7cP" firstAttribute="leading" secondItem="c7c-tA-4hz" secondAttribute="leading" constant="15" id="GQg-o4-vJR"/>
<constraint firstItem="8d0-nd-unO" firstAttribute="centerY" secondItem="kqz-lq-vil" secondAttribute="centerY" id="Gnh-AO-0es"/>
<constraint firstItem="7MY-j6-7cP" firstAttribute="top" secondItem="kqz-lq-vil" secondAttribute="bottom" constant="10" id="HFY-4o-Fdl"/>
<constraint firstAttribute="trailing" secondItem="Ha3-ef-VDs" secondAttribute="trailing" constant="15" id="JdP-4u-2Ta"/>
<constraint firstItem="nBE-fh-KJY" firstAttribute="top" secondItem="7MY-j6-7cP" secondAttribute="bottom" constant="10" id="KsW-Zt-KZ7"/>
<constraint firstItem="nBE-fh-KJY" firstAttribute="leading" secondItem="c7c-tA-4hz" secondAttribute="leading" constant="15" id="RBS-6m-boL"/>
<constraint firstItem="Ha3-ef-VDs" firstAttribute="leading" secondItem="kqz-lq-vil" secondAttribute="trailing" constant="10" id="RQK-U0-hCs"/>
<constraint firstItem="8d0-nd-unO" firstAttribute="leading" secondItem="c7c-tA-4hz" secondAttribute="leading" constant="15" id="WIC-xw-rV4"/>
<constraint firstItem="e2Y-kR-dhP" firstAttribute="top" secondItem="nBE-fh-KJY" secondAttribute="bottom" constant="20" id="ahL-YM-SEu"/>
<constraint firstItem="8d0-nd-unO" firstAttribute="top" secondItem="c7c-tA-4hz" secondAttribute="top" constant="20" id="apw-KG-E3D"/>
<constraint firstAttribute="trailing" secondItem="nBE-fh-KJY" secondAttribute="trailing" constant="15" id="cUs-po-Ebf"/>
<constraint firstItem="8d0-nd-unO" firstAttribute="top" secondItem="bVP-jU-SZv" secondAttribute="bottom" constant="20" id="cWu-Qx-xWG"/>
<constraint firstItem="kqz-lq-vil" firstAttribute="centerY" secondItem="Ha3-ef-VDs" secondAttribute="centerY" id="s7h-E7-Nhi"/>
</constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="apw-KG-E3D"/>
</mask>
</variation>
</view>
<connections>
<outlet property="eventsLogView" destination="7MY-j6-7cP" id="gfQ-Cb-Hsa"/>
<outlet property="fetchButton" destination="Ha3-ef-VDs" id="YYF-WX-Tok"/>
<outlet property="imageView" destination="nBE-fh-KJY" id="Uqa-IU-64J"/>
<outlet property="urlKeyField" destination="kqz-lq-vil" id="m6g-I9-MYR"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="gW9-uL-GMD" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1937" y="-1883"/>
</scene>
<!--Pooled Cache Sample View Controller-->
<scene sceneID="Tdo-Ed-5Jp">
<objects>
Expand Down Expand Up @@ -262,10 +350,10 @@
</objects>
<point key="canvasLocation" x="1938" y="-507"/>
</scene>
<!--Simple Cache Sample View Controller-->
<!--Data Cache Sample View Controller-->
<scene sceneID="k0N-Lz-7nd">
<objects>
<viewController id="pIu-kR-eaS" customClass="SimpleCacheSampleViewController" customModule="CarlosSample" customModuleProvider="target" sceneMemberID="viewController">
<viewController id="pIu-kR-eaS" customClass="DataCacheSampleViewController" customModule="CarlosSample" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="ZHG-sj-dxE"/>
<viewControllerLayoutGuide type="bottom" id="MgK-zE-rJV"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation
import UIKit
import Carlos

class SimpleCacheSampleViewController: BaseCacheViewController {
class DataCacheSampleViewController: BaseCacheViewController {
private var cache: BasicCache<NSURL, NSData>!

override func fetchRequested() {
Expand All @@ -12,12 +12,12 @@ class SimpleCacheSampleViewController: BaseCacheViewController {
}

override func titleForScreen() -> String {
return "Simple cache"
return "Data cache"
}

override func setupCache() {
super.setupCache()

cache = simpleCache()
cache = CacheProvider.dataCache()
}
}
3 changes: 2 additions & 1 deletion Sample/ExamplesListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ struct Example {
class ExamplesListViewController: UIViewController {
private let sections = [
ExamplesListSection(name: "Simple", samples: [
Example(name: "Simple cache", shortDescription: "memory-disk-network", segueIdentifier: "simpleCache"),
Example(name: "Image cache", shortDescription: "Out-of-the-box image cache", segueIdentifier: "imageCache"),
Example(name: "Data cache", shortDescription: "Out-of-the-box data cache", segueIdentifier: "dataCache"),
Example(name: "Memory warnings", shortDescription: "Simple stack with memory warnings listeners", segueIdentifier: "memoryWarning")
]),
ExamplesListSection(name: "Advanced", samples: [
Expand Down
Loading

0 comments on commit 111e92d

Please sign in to comment.