Note that there are some explanatory texts on larger screens.

plurals
  1. POAFNetworking EXC_BAD_ACCESS in setCompletionBlock
    primarykey
    data
    text
    <p>I'm working on an iOS app and am having some trouble with making a http request using AFNetworking. </p> <p>When I run the code I get the error: EXC_BAD_ACCESS(code=2 address=0x0). The error is occurring when I attempt to setCompletionBlock. </p> <p>I'm new to Objective-C and this has me stumped.</p> <p>Thank you in advance. Everyone's help is appreciated!</p> <pre><code>#import "AFNetworking.h" #import &lt;Cordova/CDV.h&gt; #import "UploadImg.h" @implementation UploadImg - (void) uploadImg:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options{ NSURL *url = [NSURL URLWithString:@"http://test.com/mobile/"]; AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url]; NSData *imageData = [NSData dataFromBase64String:[arguments objectAtIndex:1]]; NSMutableDictionary *params = [[NSMutableDictionary alloc] init]; [params setObject:@"TEST_STYLE" forKey:@"styleType"]; NSMutableURLRequest *request = [httpClient multipartFormRequestWithMethod:@"POST" path:@"/upload.php" parameters:params constructingBodyWithBlock: ^(id &lt;AFMultipartFormData&gt;formData) { [formData appendPartWithFileData:imageData name:@"imageName" fileName:@"image.png" mimeType:@"image/png"]; }]; AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc]initWithRequest:request]; [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"success"); } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"error"); }]; [operation start]; } @end </code></pre> <p><img src="https://i.stack.imgur.com/ZCJ4G.png" alt="enter image description here"></p> <p>Thanks again!</p>
    singulars
    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