Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/105.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Json加速器和AFN网络_Ios_Json_Afnetworking - Fatal编程技术网

Ios Json加速器和AFN网络

Ios Json加速器和AFN网络,ios,json,afnetworking,Ios,Json,Afnetworking,当操作运行时,我不能在加速器创建的JSON模型中输入数据。 你能告诉我我做错了什么吗 { [super viewDidLoad]; NSLog(@"you are in a tableViewController"); self.title = @"NavigationOrdini"; NSURLRequest *req = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.stampa6x3.com/js

当操作运行时,我不能在加速器创建的JSON模型中输入数据。 你能告诉我我做错了什么吗

{
    [super viewDidLoad];

NSLog(@"you are in a tableViewController");
self.title = @"NavigationOrdini";


NSURLRequest *req = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.stampa6x3.com/json.php?azione=ordini"]];
AFJSONRequestOperation* operation;

operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:req
                                                            success:^(NSURLRequest *request, NSURLResponse *response, id JSON)
{

    [[ordiniModel alloc] initWithDictionary:JSON];



}
             failure:^(NSURLRequest *request, NSURLResponse *response, NSError
                       *error, id JSON) {
                 [self setTitle:@"Dictionary"];
                 NSLog(@"failed! %d",[error code]);
             }];
[operation start];


ordiniModel*test;

NSLog(@"il valore è %@",test.ordini.description);

}

AFJSONRequestOperation是异步的,这意味着当应用程序的其余部分运行时,代码将继续执行。完成块在代码实际完成时运行

因此,请尝试:

NSLog(@"you are in a tableViewController");
self.title = @"NavigationOrdini";
ordiniModel *test;  // <-- create variable here

NSURLRequest *req = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.stampa6x3.com/json.php?azione=ordini"]];
AFJSONRequestOperation* operation;

operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:req
                                                            success:^(NSURLRequest *request, NSURLResponse *response, id JSON)
{

    test = [[ordiniModel alloc] initWithDictionary:JSON]; // <-- Assign here
    NSLog(@"il valore è %@",test.ordini.description);


}
             failure:^(NSURLRequest *request, NSURLResponse *response, NSError
                       *error, id JSON) {
                 [self setTitle:@"Dictionary"];
                 NSLog(@"failed! %d",[error code]);
             }];
[operation start];
NSLog(@“您在tableViewController中”);
self.title=@“NavigationOrdini”;

OrdinModel*测试;//你能说得更具体些吗?你得到了什么样的回应?您是否收到错误?响应正常!无错误[test initWithDictionary:JSON]//