Skip to content

Commit

Permalink
Add Pod files to workspace for easy access; Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kean committed Sep 19, 2015
1 parent bf2b24b commit b17cf0b
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 14 deletions.
79 changes: 79 additions & 0 deletions Example/Nuke.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Pod/Classes/Core/ImageManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public struct ImageManagerConfiguration {
public var dataLoader: ImageDataLoading
public var decoder: ImageDecoding
public var cache: ImageMemoryCaching?
public var maxConcurrentPreheatingRequests = 2
public var maxConcurrentPreheatingTasks = 2

public init(dataLoader: ImageDataLoading, decoder: ImageDecoding = ImageDecoder(), cache: ImageMemoryCaching? = ImageMemoryCache()) {
self.dataLoader = dataLoader
Expand Down Expand Up @@ -194,7 +194,7 @@ public class ImageManager: ImageManaging, ImageManagerLoaderDelegate, ImageTaskM
var executingTaskCount = self.executingTasks.count
let sortedPreheatingTasks = self.preheatingTasks.values.sort { $0.tag < $1.tag }
for task in sortedPreheatingTasks {
if executingTaskCount > self.configuration.maxConcurrentPreheatingRequests {
if executingTaskCount > self.configuration.maxConcurrentPreheatingTasks {
break
}
if task.state == .Suspended {
Expand Down
8 changes: 1 addition & 7 deletions Pod/Classes/Core/ImageManagerExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,12 @@
import UIKit

extension ImageManager {
private static var sharedManagerIvar: ImageManaging!
private static var sharedManagerIvar: ImageManaging = ImageManager(configuration: ImageManagerConfiguration(dataLoader: ImageDataLoader()))
private static var lock = OS_SPINLOCK_INIT
private static var token: dispatch_once_t = 0

public class func shared() -> ImageManaging {
var manager: ImageManaging
dispatch_once(&token) {
if self.sharedManagerIvar == nil {
let conf = ImageManagerConfiguration(dataLoader: ImageDataLoader(), cache: ImageMemoryCache())
self.sharedManagerIvar = ImageManager(configuration: conf)
}
}
OSSpinLockLock(&lock)
manager = sharedManagerIvar
OSSpinLockUnlock(&lock)
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ Nuke.taskWithRequest(request) {
```swift
let task = Nuke.taskWithURL(imageURL) {
let image = $0.image
}
task.resume()
}.resume()

// Use progress object to track load progress
let progress = task.progress
Expand All @@ -109,7 +108,7 @@ task.cancel()
#### UICollectionView

```swift
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(cellReuseID, forIndexPath: indexPath)

let imageView: ImageView = <#view#>
Expand All @@ -123,7 +122,7 @@ override func collectionView(collectionView: UICollectionView, cellForItemAtInde
Cancel image task as soon as the cell goes offscreen (optional):

```swift
override func collectionView(collectionView: UICollectionView, didEndDisplayingCell cell: UICollectionViewCell, forItemAtIndexPath indexPath: NSIndexPath) {
func collectionView(collectionView: UICollectionView, didEndDisplayingCell cell: UICollectionViewCell, forItemAtIndexPath indexPath: NSIndexPath) {
let imageView: ImageView = <#view#>
imageView.prepareForReuse()
}
Expand Down Expand Up @@ -167,7 +166,6 @@ let composition = ImageDecoderComposition(decoders: [decoder1, decoder2])
```swift
let requests = [ImageRequest(URL: imageURL1), ImageRequest(URL: imageURL2)]
Nuke.startPreheatingImages(requests: requests)

Nuke.stopPreheatingImages(requests: requests)
```

Expand Down

0 comments on commit b17cf0b

Please sign in to comment.