Memberless error with Alamofire 4.0 with Swift 3

I used Alamofire 4.0 in Swift 3.0, but got a problem with the following code

The type "Method" (aka "OpaquePointer") does not have a member "GET"

The type "Method" (aka "OpaquePointer") does not have a member "PUT"

Type "Method" (aka "OpaquePointer") does not have a "POST" member

The type "Method" (aka "OpaquePointer") does not have a member "PATCH"

The type "Method" (aka "OpaquePointer") does not have a DELETE member

Enum definition:

enum Method { case get case put case post case patch case delete func toAFMethod() -> Alamofire.Method { switch self { case .get: return Alamofire.Method.GET case .put: return Alamofire.Method.PUT case .post: return Alamofire.Method.POST case .patch: return Alamofire.Method.PATCH case .delete: return Alamofire.Method.DELETE } } } 
+4
source share
2 answers

Based on Swift 3 and Alamofire 4.0, major API changes have taken place:

 import Alamofire enum Method { case get case put case post case patch case delete func toAFMethod() -> Alamofire.HTTPMethod { switch self { case .get: return Alamofire.HTTPMethod.get case .put: return Alamofire.HTTPMethod.put case .post: return Alamofire.HTTPMethod.post case .patch: return Alamofire.HTTPMethod.patch case .delete: return Alamofire.HTTPMethod.delete } } } 

Check out the Alamofire 4.0 Migration Guide for more information.

Hope this helps you.

+10
source

The type "MusicPlayer" (aka "OpaquePointer") does not have a member "skipToNextItem" - an error code for this

 func nextButtonTapped(_ sender: UIButton) { MusicPlayer.skipToNextItem() } 

new to this, can anyone help?

0
source

Source: https://habr.com/ru/post/1258374/


All Articles