Note that there are some explanatory texts on larger screens.

plurals
  1. PO(AFNetworking) APIClient works until the second time
    primarykey
    data
    text
    <p>I'm using this method:</p> <pre><code>- (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]; } } }]; } </code></pre> <p>It works fine BUT until the second time, I mean, when I am debugging it the first time that goes to "Inicio ConexionInicio:..." it falls, i.e.: i call <code>[reload:nil]</code> in <code>ViewDidLoad</code>, so after it I inmediately needs the array that "reload" loads, but that not happens, reload returns me the array until <code>ViewDidLoad</code> finish and what I am asking is: Does anyone knows if AFNetworking always do that method until the second time?, let me show you what is <code>ConexionInicio</code>:</p> <pre><code>+ (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); } }]; } </code></pre> <p>The first time that loads it fails in <code>[[APIClient sharedClient] getPath:@"/WebConnection/ServletInicioJSON" parameters:nil success:^(AFHTTPRequestOperation *operation, id JSON)]</code> and then quits</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload