Calling depending Web Services + dispatch_group_t in iOS

What is the best approach to call the web services in a chain?

Create a dispatch group

dispatch_group_t serviceGroup;
Call the first function/web service
-(void)callFirstWebService { serviceGroup = dispatch_group_create();
//Call 1st web service here, In the completion block, call the second method which you want to perform serially [self callSecondWebService];

dispatch_group_notify(serviceGroup,dispatch_get_main_queue(),^{ // Won't get here until everything has finished NSLog(@"All Tasks finished"); //Reload table or another task which you want to perform when both service finished }); }

-(void) callSecondWebService{ dispatch_group_enter(serviceGroup); //Call 2nd web service and in the completion block, write the below code
dispatch_group_leave(serviceGroup); }

//*******************Theoretical Explantion*****************
Create a method where you want to call webservice. Depending on response, you want to call another webservice/method. After completion of all task, you want to perform las…

Semaphore | Delay splash screen in iOS + Objective C

How to wait for an asynchronously dispatched block to finish?How to integrate semaphore in iOS?How to delay splash screen for longer time, so that developer can prefetch or execute something before start of iOS App.
The answer of all the above questions is SEMAPHORE.  A semaphore is a variable or abstract data type used to control access to a common resource by multiple processes in a concurrent system such as a multiprogramming operating system. 
Suppose you want to perform some task before root view controller is shown to user.  Goto AppDelegate's method didFinishLaunchingWithOptions, create a method as below:- 
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {     [self performTaskToDelaySplash]; }
-(void) performTaskToDelaySplash {     dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); //1. Create semaphore //Perform your task here, i.e Any webservice call or any database operation

MySQL connect utility in Mac OS

Using DbVisualizer, we can connect to MySQL database on Mac.
Download the installer (select appropriate Platform & Installer Type) here
DbVisualizer offers setup for following platforms:-
Windows 32 bitWindows 64 bitMac OS XLinuxUNIX

Play youtube video in iOS app

Youtube video can be played in iOS app using webview. MPMoviePlayerController is not able to open youtube video automatically. Integrate the below script to show thumbnail, clicking on it the video will play in full screen.

NSString *url = @""; NSString* embedHTML = @"\     <html><head>\     <style type=\"text/css\">\     body {\     background-color: transparent;\     color: white;\     }\     </style>\     </head><body style=\"margin:0\">\     <iframe id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \     width=\"%0.0f\" height=\"%0.0f\" frameborder=\"0\" feature=player_detailpage allowfullscreen></iframe>\     </body></html>"; NSString* html = [NSStringstringWithFormat:embedHTML, url, self.view.frame.size.width, 200.0];
    [webviewloadHTMLString:html baseURL:nil];


Working with MongoDB

Generate a new SSH key ( If you have already ssh key generated at mac, then copy the key using:-
pbcopy < ~/.ssh/
Pass the key to your server developer (DevOps). He will give access to a server, for eg: he add your key, then open the terminal and type command:- ssh root@ You will see this in terminal:-The authenticity of host ' (' can't be established. RSA key fingerprint is SHA256:supbA7wsdvc3xXnVyHvj7fXGjlpCpt1kigJrljR4. Are you sure you want to continue connecting (yes/no)? Enter yes Enter your server addresss ( in your browser and it connects and start working. Mongo official reference for queries:-

How to show activity indicator in watch kit

To show loading indicator in watch kit without using any third party, follow the below steps:- Download the images here and add them in watch kit at xcassets (MyPWatch WatchKit App -> Assets.xcassets)Add the WKInterfaceImage (named imageLoading) to your 
WKInterfaceController Show loading indicator as belowself.imageLoading.setImageNamed("Activity") self.imageLoading.startAnimatingWithImages(in: NSMakeRange(1, 15), duration: 3.0, repeatCount: 0) To hide the indicator, do as below:- self.imageLoading.stopAnimating() self.imageLoading.setHidden(true)

Passing data to Apple Watch app from iPhone

I made a utility for transferring the data between iWatch and iPhone. This is done using the WatchConnectivity framework which is available in watch OS 2 and later.General steps to perform. Although all steps are written in the working sample code. Create the WCSessionImplement the WCSessionDelegate methods. WKInterfaceController will receive the context dictionary in one of the delegate method.In the UIViewController, Create the WCSession. When ever you want to share information to watch, then update the ApplicationContext tryWatchData.sharedInstance.session.updateApplicationContext(["message" : message])

Full working code is available at