-4

I think its been very simple question, but i'm stuck to it quite long time. I have a function but getting some brackets issue and unable to run the code. I'm not getting where the brackets should close.enter image description here

My code is,

-(void)Images{

    NSString *eachImagePath;
    if(_arrai.count == 0)
        return;

    eachImagePath = [NSString stringWithFormat:@"%@",_arrai[0]];

    NSMutableDictionary *dictAddNewJobImages = [[NSMutableDictionary alloc]init];
    dictAddNewJobImages[@"property_id"] = Propid;
    dictAddNewJobImages[@"name"] = _arrainame;

    NSString *strWebService = [NSString stringWithFormat:@"My URL"];

    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer.acceptableContentTypes=[NSSet setWithObject:@"text/html"];

    [manager.requestSerializer setTimeoutInterval:600.0];

     [manager POST:strWebService parameters:dictAddNewJobImages constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData)
     {
         NSURL *filePath = [NSURL fileURLWithPath:eachImagePath];
         [formData appendPartWithFileURL:filePath name:@"image" error:nil];
     } progress:^(NSProgress * _Nonnull uploadProgress)
     {
     } success:^(NSURLSessionDataTask*  _Nonnull *task, id  _Nullable responseObject)
     {
         NSLog(@"%@",responseObject);
         [_arrai removeObjectAtIndex:0];
         if(_arrai.count > 0)
             [self Images];
     } failure:^(NSURLSessionDataTask*  _Nullable task, NSError*  _Nonnull error) {
         NSLog(@"%@",error);
      }
    }
Anbu.Karthik
  • 82,064
  • 23
  • 174
  • 143
Hamza Imran
  • 189
  • 1
  • 18

1 Answers1

1

you forget to close your block }];

use

AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
[manager GET:XXXXXX parameters:nil progress:nil success:^(NSURLSessionTask *task, id responseObject) {
NSLog(@"JSON: %@", responseObject);
 } failure:^(NSURLSessionTask *operation, NSError *error) {
NSLog(@"Error: %@", error);
}]; --> add the close in failure

instead of

[manager GET:XXXXXX parameters:nil progress:nil success:^(NSURLSessionTask *task, id responseObject) {
NSLog(@"JSON: %@", responseObject);
 } failure:^(NSURLSessionTask *operation, NSError *error) {
NSLog(@"Error: %@", error);
}

updated answer

-(void)Images{

    NSString *eachImagePath;
    if(_arrai.count == 0)
        return;

    eachImagePath = [NSString stringWithFormat:@"%@",_arrai[0]];

    NSMutableDictionary *dictAddNewJobImages = [[NSMutableDictionary alloc]init];
    dictAddNewJobImages[@"property_id"] = Propid;
    dictAddNewJobImages[@"name"] = _arrainame;

    NSString *strWebService = [NSString stringWithFormat:@"My URL"];

    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer.acceptableContentTypes=[NSSet setWithObject:@"text/html"];

    [manager.requestSerializer setTimeoutInterval:600.0];

     [manager POST:strWebService parameters:dictAddNewJobImages constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData)
     {
         NSURL *filePath = [NSURL fileURLWithPath:eachImagePath];
         [formData appendPartWithFileURL:filePath name:@"image" error:nil];
     } progress:^(NSProgress * _Nonnull uploadProgress)
     {
     } success:^(NSURLSessionDataTask*  _Nonnull *task, id  _Nullable responseObject)
     {
         NSLog(@"%@",responseObject);
         [_arrai removeObjectAtIndex:0];
         if(_arrai.count > 0)
             [self Images];
     } failure:^(NSURLSessionDataTask*  _Nullable task, NSError*  _Nonnull error) {
         NSLog(@"%@",error);
      }]; -- > close your block here
   }
Anbu.Karthik
  • 82,064
  • 23
  • 174
  • 143