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

Vector graphics in iOS

In past, designers had to create multiple versions of the same asset (1x, 2x, 3x) to satisfy multiple screen sizes. Using vector assets can save you time because you only have to generate the asset once. You just need an.xcassets file in your project for storing your images. In there, you can declare image sets to be “Vectors”.
A vector file contains a lot of metadata of an asset that tells the system how to render it's contents, independent of the screen's resolution. This also means that whenever we get larger screen resolutions, Xcode will be able to scale up your images from your already existing vector PDF for you, giving you automatic support for future devices for free.

Select “New Image Set” in your XCAsset.Select the Attributes Inspector in Utilities panel.Under the types drop-down menu, select "Vector"Drag and drop your vector PDFUse the Xcode image catalog image set as you would with any other image. For instance, calling --imageNamed: in code, and pa…

Collection view inside table view with NO vertical scrolling

UICollectionView inside a UITableViewCell — dynamic height?
Given the following structure: TableViewTableViewCellCollectionViewCollectionViewCellCollectionViewCellCollectionViewCell[...variable number of cells or different cell sizes]
The solution is to tell auto layout to compute first the collectionViewCell sizes, then the collection view contentSize, and use it as the size of your cell. This is the UIView method that "does the magic": -(void)systemLayoutSizeFittingSize:(CGSize)targetSize      withHorizontalFittingPriority:(UILayoutPriority)horizontalFittingPriority            verticalFittingPriority:(UILayoutPriority)verticalFittingPriority

Full code is available here to download.
Thanks to this awesome answer.