Thursday, May 19, 2016

How to take screenshot automatically/ periodically on Mac by script

first, create folder and .sh file by terminal
(on this sample, "screenshot" and "Screencapture.sh")

$ cd
$ mkdir screenshot
$ cd screenshot

$ touch Screencapture.sh


Second,
create shell script


#!/bin/bash

/usr/sbin/screencapture -m -C -T0 -x ~/screenshot/capture_`date +%Y%m%d%H%M`.png



Next, permission.
$ chmod +x Screencapture.sh


Then, open your editor and copy and paste.

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">

<dict>

    <key>Label</key>

    <string>com.example.app</string>

    <key>ProgramArguments</key>

    <array>

        <string>/Users/xxxxx(username)/Screenshot.sh</string>

    </array>

    <key>StartInterval</key>

    <integer>300</integer>

</dict>

</plist>


Great, save this file as "com.example.app.plist" and locate to "/Library/LaunchDaemons"

then, run.
launchctl load -w /Library/LaunchDaemons/com.example.app.plist

You will see screen shot each 5 min.

reference
http://www.splinter.com.au/using-launchd-to-run-a-script-every-5-mins-on/




How to solve an error " Invalid or missing service identifier" on launchd


When I tried to start plist file by
launchctl load -w /Library/LaunchDaemons/com.example.app.plist

it shows:
/Library/LaunchDaemons/com.example.app.plist: Invalid or missing service identifier


check the plist file.
<key>label</key>

this was the problem.


the Label must be upper capital like ;
<key>Label</key>


then run correctly.

Sunday, May 1, 2016

how to zoom-in on the Mapkit by swift

 @IBAction func zoomInMap (sender: AnyObject) {
        let userLocation = mapView.userLocation
        let region = MKCoordinateRegionMakeWithDistance(userLocation.location!.coordinate, 800, 800)
        mapView.setRegion(region,animated:true)

    }


connect with action "zoomInMap"
set the parameter in MKCoordinateRegionMakeWithDistance property. 

How to solve "could not insert new outlet connection could not find any information for the class named viewcontroller"

It happens when I connect outlet using assistant editor on Xcode.

Just quit Xcode and restart as internet shows.
 then,,,, doesn't work.

Eventually it works when I shut down mac and restart.