Skip to content

Commit

Permalink
Documentation and Code Updates (#176)
Browse files Browse the repository at this point in the history
* Update for the latest Alamofire master, start migration guide.

* Update README, use rounded().

* Add more to migration guide.

* Add more change examples.

* It's version 3, not 2.

* Update for released AF 4, update README sample formatting.

* an -> a

* Update equality checks.
  • Loading branch information
jshier committed Sep 11, 2016
1 parent fe11f6b commit fd01db8
Show file tree
Hide file tree
Showing 16 changed files with 307 additions and 175 deletions.
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "Alamofire/Alamofire" "master"
github "Alamofire/Alamofire" ~> 4.0
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "Alamofire/Alamofire" "ee4d6ce6b4297c8554d441be3d7f53054e89fd7b"
github "Alamofire/Alamofire" "4.0.0"
2 changes: 1 addition & 1 deletion Carthage/Checkouts/Alamofire
Submodule Alamofire updated 36 files
+9 −4 .travis.yml
+1 −1 Alamofire.podspec
+1 −20 Alamofire.xcodeproj/project.pbxproj
+1 −2 Alamofire.xcodeproj/xcshareddata/xcschemes/Alamofire OSX.xcscheme
+1 −2 Alamofire.xcodeproj/xcshareddata/xcschemes/Alamofire iOS.xcscheme
+1 −2 Alamofire.xcodeproj/xcshareddata/xcschemes/Alamofire tvOS.xcscheme
+1 −2 Alamofire.xcodeproj/xcshareddata/xcschemes/Alamofire watchOS.xcscheme
+191 −18 CHANGELOG.md
+930 −0 Documentation/Alamofire 4.0 Migration Guide.md
+2 −0 Example/iOS Example.xcodeproj/project.pbxproj
+945 −679 README.md
+20 −0 Source/AFError.swift
+100 −84 Source/Alamofire.swift
+1 −1 Source/Info-tvOS.plist
+1 −1 Source/Info.plist
+3 −3 Source/MultipartFormData.swift
+18 −6 Source/ParameterEncoding.swift
+48 −72 Source/Request.swift
+84 −0 Source/Response.swift
+14 −6 Source/ResponseSerialization.swift
+3 −3 Source/ServerTrustPolicy.swift
+17 −2 Source/SessionDelegate.swift
+204 −119 Source/SessionManager.swift
+10 −50 Source/TaskDelegate.swift
+6 −1 Source/Validation.swift
+1 −1 Tests/AuthenticationTests.swift
+34 −34 Tests/DownloadTests.swift
+34 −4 Tests/ParameterEncodingTests.swift
+21 −46 Tests/RequestTests.swift
+1 −1 Tests/ResponseSerializationTests.swift
+163 −110 Tests/ResponseTests.swift
+8 −8 Tests/SessionDelegateTests.swift
+227 −11 Tests/SessionManagerTests.swift
+4 −6 Tests/URLProtocolTests.swift
+44 −92 Tests/UploadTests.swift
+63 −69 Tests/ValidationTests.swift
130 changes: 130 additions & 0 deletions Documentation/AlamofireImage 3.0 Migration Guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# AlamofireImage 3.0 Migration Guide

AlamofireImage 3.0 is the latest major release of AlamofireImage, an image component library for Alamofire supporting iOS, tvOS, macOS and watchOS written in Swift. As a major release, following Semantic Versioning conventions, 3.0 introduces several API-breaking changes that one should be aware of.

This guide is provided in order to ease the transition of existing applications using AlamofireImage 2.x to the latest APIs, as well as explain the design and structure of new and changed functionality.

## Requirements

- iOS and tvOS 9.0+, macOS 10.11+, watchOS 2.0+
- Xcode 8.0+
- Swift 3.0+

For those of you that would like to use AlamofireImage on iOS 8 or macOS 10.9, please use the latest tagged 2.x release which supports both Swift 2.2 and 2.3.

## Benefits of Upgrading

The benefits of upgrading can be summarized as follows:

- **Alamofire 4 Compatability**
- **Complete Swift 3 Compatibility:** includes the full adoption of the new [API Design Guidelines](https://swift.org/documentation/api-design-guidelines/).
- **New Error System:** uses a new `AFIError` type to adhere to the new pattern proposed in [SE-0112](https://github.com/apple/swift-evolution/blob/master/proposals/0112-nserror-bridging.md).

---

## Breaking API Changes

AlamofireImage 3 has fully adopted the new Swift 3 changes and conventions, including the new [API Design Guidelines](https://swift.org/documentation/api-design-guidelines/). Because of this, almost every API in AlamofireImage has been modified in some way. We can't possibly document every single change, so we're going to attempt to identify the most common APIs and how they have changed to help you through those sometimes less than helpful compiler errors. If you're interested in the underlying Alamofire 4 changes, read the [migration guide](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Alamofire%204.0%20Migration%20Guide.md).

### Requests

```swift
// AlamofireImage 2
Alamofire.request(.GET, "https://httpbin.org/image/png")
.responseImage { response in
if let image = response.result.value {
print("image downloaded: \(image)")
}
}

// AlamofireImage 3
Alamofire.request("https://httpbin.org/image/png")
.responseImage { response in
if let image = response.result.value {
print("image downloaded: \(image)")
}
}
```

### UIImage and UIImageView Extensions

The `UIImage` and `UIImageView` extensions have undergone extensive renaming.

#### Loading an Image

```swift
// AlamofireImage 2
imageView.af_setImageWithURL(URL,
placeholderImage: placeholderImage,
filter: filter)

// AlamofireImage 3
imageView.af_setImage(withURL: url,
placeholderImage: placeholderImage,
filter: filter)
```

#### Loading an Image with Placeholder, Filter and Transition

```swift
// AlamofireImage 2
imageView.af_setImageWithURL(URL,
placeholderImage: placeholderImage,
filter: filter,
imageTransition: .CrossDissolve(0.2))

// AlamofireImage 3
imageView.af_setImage(withURL: url,
placeholderImage: placeholderImage,
filter: filter,
imageTransition: .crossDissolve(0.2))

```

### Image Cache

#### Getting an Image

```swift
// AlamofireImage 2
let cachedAvatar = imageCache.imageWithIdentifier("avatar")

// AlamofireImage 3
let cachedAvatar = imageCache.image(withIdentifier: "avatar")
```

#### Adding an Image

```swift
// AlamofireImage 2
imageCache.addImage(avatarImage, withIdentifier: "avatar")

// AlamofireImage 3
imageCache.add(avatarImage, withIdentifier: "avatar")

// With an Additional Identifier

// AlamofireImage 2
imageCache.addImage(avatarImage, forRequest: urlRequest, withAdditionalIdentifier: "circle")

// AlamofireImage 3
imageCache.add(avatarImage, for: urlRequest, withIdentifier: "circle")
```

#### Removing an Image

```swift
// AlamofireImage 2
imageCache.removeImageWithIdentifier("avatar")

// AlamofireImage 3
imageCache.removeImage(withIdentifier: "avatar")

// With an Addtional Identifier

// AlamofireImage 2
imageCache.removeImageForRequest(urlRequest, withAdditionalIdentifier: "circle")

// AlamofireImage 3
imageCache.removeImage(for: urlRequest, withIdentifier: "circle")
```
2 changes: 1 addition & 1 deletion Example/ImagesViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ extension ImagesViewController : UICollectionViewDataSource {
let gravatar = gravatars[(indexPath as NSIndexPath).row]

cell.configureCell(
with: gravatar.url(size: sizeForCollectionViewItem().width).urlString,
with: gravatar.url(size: sizeForCollectionViewItem().width).absoluteString,
placeholderImage: placeholderImage
)

Expand Down
Loading

0 comments on commit fd01db8

Please sign in to comment.