0

Here is my code.

-(void)aaaa{
[AFNetworkActivityIndicatorManager sharedManager].enabled=YES;
[[ClientAPI sharedClient] POST:@"api/expert/get-tests.php" parameters:nil success:^(NSURLSessionDataTask *task, id content){
    NSLog(@"nslogjson: %@%@",task.response,content );} 
failure:^(NSURLSessionDataTask *task,NSError *error){NSLog(@"%@",error);}];
[AFNetworkActivityIndicatorManager sharedManager].enabled=YES;
}

I don't want to NSlog these data.I want get "content" return back to an other class.How to do?

ChintaN -Maddy- Ramani
  • 5,156
  • 1
  • 27
  • 48

2 Answers2

1

Time to use blocks:

- (void)aaaaWitCompletion:(void (^)(id response)completionBLock {

[[ClientAPI sharedClient] POST:@"api/expert/get-tests.php" parameters:nil success:^(NSURLSessionDataTask *task, id content){
    NSLog(@"nslogjson: %@%@",task.response,content);
    if (completionBLock) {
    completionBLock(task.response);
    }
} 
failure:^(NSURLSessionDataTask *task,NSError *error){
    NSLog(@"%@",error);
    }];
}

//  Somewhere in your code:

- (void)updateButtonAction:(id)sender {

   [self aaaaWitCompletion:^(id response) {
//  Use your response here
   }];
}
orkenstein
  • 2,810
  • 3
  • 24
  • 45
-1
class 2

@property(NSDictionary*) json;

class 1
//json
class2obj2=[[class2 alloc] init];
class2obj.json=json;
[self.navigationcontroller pushViewController:class2obj];
djmunish
  • 31
  • 3
  • Make a property in another class of type NSDictionary and before pushing view controller assign the json to this property. then you have your data in this json property of class 2 – djmunish Nov 17 '14 at 06:39