Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @implementation databaseCntcn{
- MongoConnection *conn;
- AppDelegate* appdel;
- }
- -(BOOL)connection{
- @try {
- appdel =(AppDelegate*)[[UIApplication sharedApplication]delegate];
- if (appdel.isNetOn) {
- NSError *error = nil;
- conn =[MongoConnection connectionForServer:@"myhost/port" error:&error];
- [conn authenticate:@"admin" username:@"myusername" password:@"mypassword" error:&error];
- if (conn) {
- NSLog(@"true");
- return true;
- }
- else{
- UIAlertView *a=[[UIAlertView alloc]initWithTitle:@"Cannot connect to server" message:@"Please check your internet connection" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil];
- [a show];
- }
- }
- else{
- }
- return false;
- }
- @catch (NSException *exception) {
- } @finally {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement