title: Switching from AFNetworking to RestKit
body: <p>I started developing my application using AFNetworking. Everything went OK till I want to use core data. I know there is an additional class (AFIncrementalStore) for that. But because I'm new to IOS-development and there is not a lot of information about that. I decided to switch to RestKit because here is a lot more information. Now, I followed a tutorial about AFNetworking. Here I created an API class which this method in it.</p>
  
  <pre><code>+(API *)sharedInstance
  {
      static API *sharedInstance = nil;
      static dispatch_once_t oncePredicate;
      dispatch_once(&amp;oncePredicate, ^ {
          sharedInstance = [[self alloc]initWithBaseURL:[NSURL URLWithString:kAPIHost]];
      });
      return sharedInstance;
  }
  
  #pragma mark - init
  //intialize the API class with the destination host name
  
  -(API *)init
  {
      //call super init
      self = [super init];
  
      if (self != nil){
          //initialize the object
          user = nil;
  
          [self registerHTTPOperationClass:[AFJSONRequestOperation class]];
  
          // Accept HTTP Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1
          [self setDefaultHeader:@"Accept" value:@"application/json"];
      }
      return self;
  }
  
  -(void)loginCommand:(NSMutableDictionary *)params onCompletion:(JSONResponseBlock)completionBlock{
      NSLog(@"%@%@",kAPIHost,kAPILogin);
      NSMutableURLRequest *apiRequest = [self multipartFormRequestWithMethod:@"POST" path:kAPILogin parameters:params constructingBodyWithBlock:^(id &lt;AFMultipartFormData&gt;formData){
          //TODO: attach file if needed
  
      }];
      AFJSONRequestOperation *operation = [[AFJSONRequestOperation alloc] initWithRequest:apiRequest];
      [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject){
          //success!
          NSLog(@"SUCCESSSS!");
          completionBlock(responseObject);
      }failure:^(AFHTTPRequestOperation *operation, NSError *error){
          //Failure
          NSLog(@"FAILUREE!");
          completionBlock([NSDictionary dictionaryWithObject:[error localizedDescription] forKey:@"error"]);
      }];
      [operation start];
  
  }
  </code></pre>
  
  <p>This handles the communication between my webservice and application. 
  In the viewControler itself I call this method like this.</p>
  
  <pre><code>   /*  [[API sharedInstance] loginCommand:[NSMutableDictionary dictionaryWithObjectsAndKeys:_txtLogin.text,@"email",_txtPass.text,@"pwd", nil] onCompletion:^(NSDictionary *json){
       //completion
           if(![json objectForKey:@"error"]){
               NSLog(@"status %@",[json valueForKeyPath:@"data.status"]);
               if([[json valueForKeyPath:@"data.status"]intValue] == 200){
                    // Everything is oké, and login is succesfull
               }else{
                   //show validation
               }
           }else {
               NSLog(@"Cannot connect to the server");
           }
       }];*/
  </code></pre>
  
  <p>This is how I do this in AFnetworking. But what are the differences when I do this in RestKit. I searched for tutorials. But after the update from RestKit 1.0 to 2.0 a lot of these tutorials are outdated. So I hope anybody can help me out with this!</p>
  
  <p>Kind regards!</p>