本文介绍了Strongloop iOS用户创建错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下代码在服务器中创建并保存测试用户:

I'm trying to create and save a test user in server with this code:

LBRESTAdapter *adapter = ((AppDelegate *)[[UIApplication sharedApplication] delegate]).adapter;
    if (adapter) {
            TeacherRepository *repo = (TeacherRepository *)[adapter repositoryWithClass:[TeacherRepository class]];
            if (repo) {
                Teacher *st = (Teacher *)[repo createUserWithEmail:@"test@test.com" password:@"test"];
                if (st) {
                    [st saveWithSuccess:^{
                        NSLog(@"Saved in server!");
                    } failure:^(NSError *error) {
                        NSLog(@"Error: %@", error.description);
                    }];
                }
            }
       }

但我一直在继续错误响应:

but I keep on getting this error response:

Error Domain=AFNetworkingErrorDomain Code=-1011 "Expected status code in (200-299), got 404"

我已经搜索了此错误和其他类似错误,但是找不到任何可以解决我的问题的方法,

I have searched for this error and similar others, but couldn't find anything that would solve my problem, so what could be causing this?

推荐答案

(即404)表示找不到资源:

The HTTP Status Code of 404 means that the resource was not found:

它似乎表明您的AFNetworking代码中的URL构建错误。您尚未共享那部分代码,因此很难在细节上发表评论。我认为,如果您记录整个 error 对象(而不仅仅是 error.description ),它将向您显示尝试的URL使用失败。

It would appear that there is an error in the building of the URL in your AFNetworking code. You haven't shared that portion of code, so it's hard to comment on the specifics. I think if you log the entire error object (not just error.description) it will show you what URL it attempted to use unsuccessfully.

这篇关于Strongloop iOS用户创建错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 20:31