Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. func sendLoginRequest(userName:String,password:String){
  2.  
  3. let authenticate:String = String(format: "%@:%@", userName, password)
  4. let plainData = (authenticate as NSString).dataUsingEncoding(NSUTF8StringEncoding)
  5. let base64String = plainData!.base64EncodedStringWithOptions(NSDataBase64EncodingOptions(rawValue: 0))
  6. print(base64String)
  7. headers = ["Authorization" : String(format: "Basic %@", base64String)]
  8. self.webInterface = DFWebInterface.shareWebInterface(DFModel.sharedInstance.bMockServer)
  9.  
  10. self.webInterface?.sendRequest(nil,request: LOGIN.rawValue, nil,headers: headers as! [NSObject : AnyObject])
  11. }
  12.  
  13. -(id)init:(NSString*)strURL :(BOOL)mockServer{
  14. if(nil!=(sDFWebInterface=[super init])){
  15. NSURL *baseURL = [NSURL URLWithString:strURL];
  16. DFAFHTTPClient* client=[[DFAFHTTPClient alloc] initWithBaseURL:baseURL];
  17. sDFWebInterface->rkobjmanagerDF = [[RKObjectManager alloc] initWithHTTPClient:client];
  18. [RKMIMETypeSerialization registerClass:[RKNSJSONSerialization class] forMIMEType:@"text/plain"];
  19.  
  20. [AFNetworkActivityIndicatorManager sharedManager].enabled = YES;
  21. }
  22.  
  23. return sDFWebInterface;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement