Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/109.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.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 如何使用AFN网络检测删除状态?_Ios_Objective C_Afnetworking_Delete Row - Fatal编程技术网

Ios 如何使用AFN网络检测删除状态?

Ios 如何使用AFN网络检测删除状态?,ios,objective-c,afnetworking,delete-row,Ios,Objective C,Afnetworking,Delete Row,我想删除列表中的1条记录。如何在我的代码中检测删除状态,如下所示?我想在我的应用程序中显示删除状态警报(如成功或未成功)。请帮忙 NSString *wishlistID = @"5"; NSString *url_string = [NSString stringWithFormat: @"http://api.stardomtechs.com/api/product/wishlist_delete/%@",wishlistID];

我想删除列表中的1条记录。如何在我的代码中检测删除状态,如下所示?我想在我的应用程序中显示删除状态警报(如成功或未成功)。请帮忙

NSString *wishlistID = @"5";
                NSString *url_string = [NSString stringWithFormat: @"http://api.stardomtechs.com/api/product/wishlist_delete/%@",wishlistID];
                [self.manager DELETE:url_string parameters:nil success:^(NSURLSessionDataTask *task, id responseObject) {

                //HOW CAN I CHECK STATUS HERE?? IF DELETED, SHOW SUCCESSFUL MESSAGE ELSE ERROR MESSAGE
                [self.collectionView reloadData];
                }
                failure:^(NSURLSessionDataTask *task, NSError *error) {

                    UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Please try again"
                                                                                     message:[error localizedDescription]
                                                                              preferredStyle:UIAlertControllerStyleAlert];

                    UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"Ok"
                                                                       style:UIAlertActionStyleCancel
                                                                     handler:nil];

                    [alertVC addAction:okAction];

                    [self presentViewController:alertVC animated:YES completion:nil];
                }];

这实际上取决于API设计。如果API没有发送任何关于更新列表或其他内容的响应正文,则http状态代码200足以让客户端理解这是一次成功的通信。我假设如果删除成功,API将返回success,状态代码为200。所以,如果error为nil,这意味着删除完成,您可以显示一条消息。嗨,Sharad,您能在这里分享一些示例代码吗?所以我有一些基本的想法,谢谢!查看AFN网络文档。