Programmatically Screenshot | Swift 3, macOS

Yes its possible. This function takes all connected monitors screenshots and writes to specified path as jpg file. Generates file name as unix time stamp. func TakeScreensShots(folderName: String){ var displayCount: UInt32 = 0; var result = CGGetActiveDisplayList(0, nil, &displayCount) if (result != CGError.success) { print(“error: \(result)”) return } let allocated = Int(displayCount) let activeDisplays = … Read more

No Such Module ‘Parse’

I just had this problem, and I got it to work by doing this: I opened my Target > Build Settings > Search Paths > Framework Search Paths. I added two values: $(PROJECT_DIR) and $(inherited) I don’t know why these were empty in the first place, but there you have it.

How do I do weak linking in Swift?

Seems like I’ve figured out what you can do I used NSClassFromString() to check if class is available on device, i.e. if NSClassFromString(“UIBlurEffect”) { let blur = UIBlurEffect(…) //… } else { //… } It’s needed to make UIKit.framework (or another corresponding framework) optional. If you create Swift-based application in XCode6-BetaX, all the frameworks wouldn’t … Read more

Get the frame of UIBarButtonItem in Swift?

You should try it like: var barButtonItem = self.navigationItem.rightBarButtonItem! var buttonItemView = barButtonItem.valueForKey(“view”) var buttonItemSize = buttonItemView?.size Edit (Swift 3): var barButtonItem = self.navigationItem.rightBarButtonItem! let buttonItemView = barButtonItem.value(forKey: “view”) as? UIView var buttonItemSize = buttonItemView?.size

google maps iOS SDK: custom icons to be used as markers

Here is what I have done let marker = GMSMarker() // I have taken a pin image which is a custom image let markerImage = UIImage(named: “mapMarker”)!.withRenderingMode(.alwaysTemplate) //creating a marker view let markerView = UIImageView(image: markerImage) //changing the tint color of the image markerView.tintColor = UIColor.red marker.position = CLLocationCoordinate2D(latitude: 28.7041, longitude: 77.1025) marker.iconView = markerView … Read more

WKWebView function for detecting if the URL has changed

Swift Version // Add observer webView.addObserver(self, forKeyPath: “URL”, options: .new, context: nil) // Observe value override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) { if let key = change?[NSKeyValueChangeKey.newKey] { print(“observeValue \(key)”) // url value } }