(AFNetworking)APIClient一直工作到第二次

时间:2013-02-01 15:22:12

标签: ios objective-c afnetworking

我正在使用这种方法:

- (void)reload:(id)sender {
    mutableImagenes=[[NSMutableArray alloc]init];
     NSMutableArray *arrayImagenes=[[NSMutableArray alloc] init];
    [Inicio ConexionInicio:^(NSArray *imagenesArray, NSError *error) {
        if (error) {
            [[[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Error", nil) message:[error localizedDescription] delegate:nil cancelButtonTitle:nil otherButtonTitles:NSLocalizedString(@"OK", nil), nil] show];
        } else {
            _ArrayInicio = imagenesArray;
            for(Inicio *i in _ArrayInicio){
                [mutableImagenes addObject:i];
            }
        }
    }];
}

它工作正常但直到第二次,我的意思是,当我第一次调试它时,它会进入“Inicio ConexionInicio:......”它会下降,即:我在{{1}中调用[reload:nil]所以在它之后我立即需要“重载”加载的数组,但是没有发生,重新加载会返回数组,直到ViewDidLoad完成,而我要问的是:有没有人知道AFNetworking是否总是这样做直到第二次?,让我告诉你什么是ViewDidLoad

ConexionInicio

第一次加载它在+ (void)ConexionInicio:(void (^)(NSArray *imagenesArray, NSError *error))block { [[APIClient sharedClient] getPath:@"/WebConnection/ServletInicioJSON" parameters:nil success:^(AFHTTPRequestOperation *operation, id JSON) { NSArray *imagenesFromResponse = [JSON valueForKeyPath:@"Inicio"]; NSMutableArray *mutableImagenes = [NSMutableArray arrayWithCapacity:[imagenesFromResponse count]]; for (NSDictionary *attributes in imagenesFromResponse) { Inicio *i = [[Inicio alloc] initWithAttributes:attributes]; [mutableImagenes addObject:i]; } if (block) { block([NSArray arrayWithArray:mutableImagenes], nil); } } failure:^(AFHTTPRequestOperation *operation, NSError *error) { if (block) { block([NSArray array], error); } }]; } 失败然后退出

0 个答案:

没有答案