title: which one is better to wrap AFNetworking functions in one file or use it in separate files,
body: <p>I'm using AFNetworking as network library. There are two different coding styles and I don't know which one is better.</p>
  
  <ol>
  <li><p>Wrap all functions that associated to network to one file.
  For example, I have a singleton file called API.m, and I wrapped <code>login</code> function as below:</p>
  
  <pre><code>- (void) login:(NSString *)username withPassword:(NSString *)password
    andCompletionBlock:(void(^)(NSString*))block andFailBlock:(void(^)())failBlock
  {
    NSMutableString *url = [[NSMutableString alloc] initWithCapacity:10];
    [url appendString:LOGINURL];
  
    NSURL* nurl = [NSURL URLWithString:url];
    NSURLRequest *request = [NSURLRequest requestWithURL:nurl];
    AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
    [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
    NSString *requestTmp = [NSString stringWithString:operation.responseString];
      block(requestTmp);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
      failBlock();
    }];
    [operation start];
  }
  </code></pre></li>
  </ol>
  
  <p>Then in <code>LoginViewController</code>, I can call this function to do my login job:</p>
  
  <pre><code>    [[ServerAPI Instance] login:@"hello" withPassword:@"world" 
      andCompletionBlock:^(NSString *str) {} failBlock^(){}];
  </code></pre>
  
  <ol start="2">
  <li>Write the network process code directly in separate view controllers.</li>
  </ol>
  
  <p>Which one is a better coding style? </p>