我正在创建一个使用restkit的IOS应用程序,我能够做GET请求没有问题,并且它正确地映射了一切但是,我无法让restkit对数据库进行POST.它正在回应说:
`{"errors":{"email":["can't be blank"],"password":["can't be blank"]}}`
Run Code Online (Sandbox Code Playgroud)
我感觉这个物体没有被发送.这是我在我的app委托中设置所有映射的代码.
RKObjectMapping *userMapping = [RKObjectMapping mappingForClass:[User class]];
RKObjectMapping *dogMapping = [RKObjectMapping mappingForClass:[Dog class]];
RKObjectMapping *posttimeMapping = [RKObjectMapping mappingForClass:[PostTime class]];
RKObjectMapping *postMapping = [RKObjectMapping mappingForClass:[Post class]];
RKObjectMapping *activityMapping = [RKObjectMapping mappingForClass:[Activity class]];
// set up which attributes go where
[userMapping addAttributeMappingsFromDictionary:[User propertyMappings]];
[dogMapping addAttributeMappingsFromDictionary:[Dog propertyMappings]];
[posttimeMapping addAttributeMappingsFromDictionary:[PostTime propertyMappings]];
[postMapping addAttributeMappingsFromDictionary:[Post propertyMappings]];
[activityMapping addAttributeMappingsFromDictionary:[Activity propertyMappings]];
// set up relationships
[userMapping addRelationshipMappingWithSourceKeyPath:@"dogs" mapping:dogMapping];
[dogMapping addRelationshipMappingWithSourceKeyPath:@"timeline" mapping:posttimeMapping];
[posttimeMapping addRelationshipMappingWithSourceKeyPath:@"posts" mapping:postMapping];
[postMapping addRelationshipMappingWithSourceKeyPath:@"activities" mapping:activityMapping];
// what to print
RKLogConfigureByName("RestKit/Network", …Run Code Online (Sandbox Code Playgroud) 我试图改变UIViewControllerRepresentable的@State,并注意到updateUIViewController(_ uiViewController:context:)我后不会被调用。
我不知道这是一个错误还是我做错了什么。
例如:
struct ContentView: UIViewControllerRepresentable {
@State var blah: Int = 0
func makeUIViewController(context: UIViewControllerRepresentableContext<ContentView>) -> UIViewController {
let vc = UIViewController()
let button = UIButton(frame: CGRect(x: 40, y: 40, width: 100, height: 100))
button.setTitle("Next", for: .normal)
button.addTarget(context.coordinator, action: #selector(context.coordinator.nextPressed), for: .primaryActionTriggered)
vc.view.addSubview(button)
return vc
}
func updateUIViewController(_ uiViewController: UIViewController, context: UIViewControllerRepresentableContext<ContentView>) {
// Not being called when `blah` is updated.
var random = SystemRandomNumberGenerator()
let red = CGFloat(Double(random.next() % 255) / …Run Code Online (Sandbox Code Playgroud)