Advertisement
Guest User

Untitled

a guest
Jul 1st, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. @implementation databaseCntcn{
  2. MongoConnection *conn;
  3. AppDelegate* appdel;
  4. }
  5.  
  6. -(BOOL)connection{
  7.  
  8. @try {
  9. appdel =(AppDelegate*)[[UIApplication sharedApplication]delegate];
  10. if (appdel.isNetOn) {
  11. NSError *error = nil;
  12. conn =[MongoConnection connectionForServer:@"myhost/port" error:&error];
  13. [conn authenticate:@"admin" username:@"myusername" password:@"mypassword" error:&error];
  14. if (conn) {
  15. NSLog(@"true");
  16.  
  17. return true;
  18. }
  19. else{
  20. UIAlertView *a=[[UIAlertView alloc]initWithTitle:@"Cannot connect to server" message:@"Please check your internet connection" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil];
  21. [a show];
  22. }
  23.  
  24. }
  25. else{
  26.  
  27. }
  28. return false;
  29. }
  30. @catch (NSException *exception) {
  31.  
  32. } @finally {
  33.  
  34. }
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement