Skip to content

'NSInvalidArgumentException', reason: '*** -propertyForKey: only defined for abstract class #250

Open
@konomae

Description

@konomae

Hi

I found this exception in Crashlytics crash logs from my production app.
I can reproduce and paste it bellow. But I cannot find how to fix it.
So, I just report this.

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -propertyForKey: only defined for abstract class.  Define -[_TtCV6APIKit31MultipartFormDataBodyParameters20MultipartInputStream propertyForKey:]!'
  • Xcode 8.3.3
  • iOS 10.3 SDK
  • iPhone Plus (iOS 10.3 simulator)
import UIKit
import APIKit

protocol HttpBinRequest: Request {

}

extension HttpBinRequest {
    var baseURL: URL {
        return URL(string: "https://httpbin.org")!
    }
}

struct PostRequest: HttpBinRequest {
    typealias Response = Any

    var method: HTTPMethod {
        return .post
    }

    var path: String {
        return "/post"
    }

    var bodyParameters: BodyParameters? {
        let p = try! MultipartFormDataBodyParameters.Part(
            value: "value",
            name: "name"
        )

        return MultipartFormDataBodyParameters(parts: [p], entityType: .inputStream)
    }

    func response(from object: Any, urlResponse: HTTPURLResponse) throws -> Response {
        return object
    }
}

class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()

        let request = PostRequest()

        Session.send(request) { result in
            print(result)
            switch result {
            case .success(let response):
                print(response)
            case .failure(let error):
                print("error: \(error)")
            }
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions