Blog

How to Use an Apple Watch for Running Interval Training

There are six key issues when using the Apple Watch for interval training on the track:

  1. How to start the Watch at the right time,
  2. How to capture lap times,
  3. How to easily see the elapsed time,
  4. How to disable notifications,
  5. How to pause the workout, and
  6. How to export the workout to Strava.

I initially tried using the Strava app, but there’s no option to capture lap times. I then looked at the built-in Workout app.

Although the Workout app has a 3-2-1 countdown when you start a new activity, if you tap the screen during the countdown it will immediately start the activity.

As for capturing lap times, you just have to double-tap the screen. In practice I never have a 100% success rate, but good enough to capture most laps. You can review the lap times later in the “Activity” iPhone app, under the “workouts” tab.

If you can’t see the display clearly while running, you can change the Workout View to only show a ‘single metric’, instead of the default ‘multiple metric’. In single metric mode you turn the Digital Crown to change the metric that’s shown. Open the Watch App then scroll down to the Workout App. Tap the Workout App and the first item is ‘Workout View’. Tap to toggle between Multiple and Single Metric.

In order to disable notifications from popping up during your workout, open the Watch App, tap on General, then tap on ‘Do Not Disturb’. Then you’ll see an option called ‘Workout Do Not Disturb’ that you can toggle on and off.

To pause the workout you need to press both the crown and side button at the same time.

That just leaves how to export the workouts to Strava. I found an iPhone app called “HealthFit” which displays your workouts, and has various export options, including Strava. I also use HealthFit to export my swim workouts ( the Strava Apple Watch app has no option for swimming).

Taking the JLPT N2

After passing the JLPT N3 exam with almost all the questions correct, and being in the top 3% globally, I signed up for the JLPT N2 exam, three months later.

In summary, three months is not nearly enough time to go from N3 level to N2 – there’s especially a big jump in the number of Japanese words / Kanji you need to know. Even the listening is a lot harder than N3.

The worst thing is that you only get informed of your results by mail, a couple of weeks after the closing date of entry. You need to know to check the results online before the two weeks during which entries for the next exam are open. As a result, it will be 9 months until I can take the N2 exam again. At least by then I should be ready 🙁

Update: I passed JLPT N2 in December 2021.

How FM Tuners are Different in the USA

I recently bought an Onkyo TX-8220 2 Channel Stereo Receiver with Bluetooth from the USA, instead of buying here in Singapore, because locally they seem to be very over-priced.

I was hoping that Onkyo would use international power supplies, but when it arrived, and I checked the unit itself, I found that it only supported 120V AC input. Luckily I already had a 240V->120V transformer, so no issue.

The big surprise came when I tried to tune the radio to Singapore radio stations. I couldn’t understand initially why it wouldn’t pick up many of the expected radio stations. After some searching online, I found the answer.

To avoid interference, FM radio stations in the USA only use odd-numbered frequencies. In Singapore, and other countries, FM radio stations can use even numbered frequencies as well. The Onkyo FM tuner could only tune to odd-numbered frequencies!

I’m not sure how easy it would be to change that, but at least I can either 1. use a radio app on my TV, or 2. stream radio from an iPhone via Bluetooth.

Next time I’ll look for a European model instead!


Preparation for JLPT N3

I took the JLPT N3 exam last December. I found the following resources to be useful:

IOS Apps:

  1. JLPT Study – let’s you test your knowledge of Kanji or Vocabulary, sorted by level, N5 all the way to N1. I’ve ignored the Kanji, and am just going for the Vocabulary.
  2. Quizlet – let’s you create your own flash cards for Kanji / words you don’t know. I’ve created two sets: one for words I don’t know in the various JLPT N3 books, and one for other words I come across that I don’t know – could be any level.
  3. Google translate – let’s me enter Japanese text by typing or writing the Kanji. the translation is often not so accurate, but good enough.
  4. aNote (awesome note) – let’s me copy and paste or enter Japanese words, but in a large font size for readability. Any app where you can specify the font size should do. If I also highlight the text it gives me the option to ‘lookup’ the word in the iPhone built-in Japanese dictionaries which is quicker than using Google Translate.

Websites:

  1. news.tbs.co.jp – excellent resource – short news clips, complete with corresponding transcriptions. You can either watch the video, or try and read the transcription, or do both!
  2. jisho.org – I use this for looking up Kanji. In the search field enter #kanji followed by the Kanji you want to look up.

Books:

I started with reading:

N3 読む 文章の文法。読解 published by UNICOM Inc. ISBN978-4-89689-471-4

This book was pretty good for reading practise. I then decided to try a practise test to see where I needed to focus on. Seems that the only official practise papers are published by 凡人社 – 公式問題集N3. My weak point was grammar.

After checking reviews I then bought TRY!文法から伸ばす日本語 published by ASK. ISBN978-4-87217-902-6.

This book is well organised. Even better it has English explanations for the grammar points. This book definitely helped me prepare for the grammar questions.

If you go to amazon.co.jp you can buy kindle books in Japanese. Books for kids will tend to have フリガナ which really helps to learn Kanji. The Kindle app also has built in dictionary and translation looks ups, so you can select a sentence or phrase and get the translation (warning – not always correct!).

I haven’t got the results yet (takes 2 months!), but have started working on JLPT N2…

-Stuart.

How to Create Ringtones for iPhone from any audio

You can create ringtones for iPhone on your mac by following the steps below.

  1. Install iShowU Audio Capture from here. This gives you the ability to redirect audio playing on your macbook to GarageBand or other applications.
  2. Go to System Preferences…Audio and set the Output to be ‘iShowU Audio Capture’.
  3. Record the audio you want to turn into a ringtone using GarageBand or another application. In the case of GarageBand you can create a new Project and choose ‘Record Using a Microphone or line input’. Although you won’t hear what you’re recording, you’ll see the levels for the track move up and down.
  4. Go back to ‘System Preferences…Audio’ on the mac and change the Output back to ‘Internal Speakers’. Then go ahead and edit the Audio you recorded in step 3.
  5. Export/save to disk the audio as AAC. Note: the total length has to be 30 sec or under. Don’t use any special characters in the file name.
  6. In Finder, locate the file and change the file extension from m4v to m4r.
  7. In iTunes, make sure your iPhone is connected (via wifi or cable), and under your device there should be a submenu item called ‘Tones’. Click on that item to open it.
  8. Drag and drop the m4r file from Finder to the right-hand side of iTunes. It should then be listed if successful.
  9. on the iPhone go to settings…Sounds…then tap on ‘Ringtone’. You should then see your new ringtone listed at the top under  the ‘RINGTONES’ section. Select it, and you’re done!

Note: I’ve tried this once so far. It works, but I have some issues with the quality of the audio in the ringtone. Need to figure that out…

How to copy Objects in Swift

I wanted to populate an array with multiple unique copies of an existing object. If you just append the same object in a loop, you just end up with an array with multiple references to the one object!

I thought that there would be a simple way to copy the instance of an object in Swift. I was wrong! The simplest way is to use copy() which requires the following three steps:

  1. Make your class conform to NSCopying. This isn’t strictly required, but it makes your intent clear.
  2. Implement the method copy(with:), where the actual copying happens.
  3. Call copy() on your object.

See hackingwithswift.com for more details…

 

How to add a ‘Done’ button to a numberPad in Swift

The best way to add a ‘Done‘ button to a numberPad, which doesn’t have it by default,  is to extend UITextField. Three steps:

1. set the keyboard type for your UITextField in your viewController subclass:

e.g. myTextField.keyboardType = UIKeyboardType.numberPad

2. save the code below the line as  ‘UITextField+Extensions.swift’ and add to your project.

3. After this, if you select any UITextField in the storyboard editor, there will be a new item under the ‘Attributes Inspector’ for that UITextField, where you can set ‘Done Access…’ On, Off or default. Choose ‘On’ if you want the ‘Done’ button to show up.


import Foundation

import UIKit

extension UITextField{

       @IBInspectable var doneAccessory: Bool{

        get{

            return self.doneAccessory

        }

        set (hasDone) {

            if hasDone{

                addDoneButtonOnKeyboard()

            }

        }

    }

    

    func addDoneButtonOnKeyboard()

    {

        let doneToolbar: UIToolbar = UIToolbar(frame: CGRect.init(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 50))

        doneToolbar.barStyle = .default

        

        let flexSpace = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)

        let done: UIBarButtonItem = UIBarButtonItem(title: “Done”, style: .done, target: self, action: #selector(self.doneButtonAction))

        

        let items = [flexSpace, done]

        doneToolbar.items = items

        doneToolbar.sizeToFit()

        

        self.inputAccessoryView = doneToolbar

    }

    

    @objc func doneButtonAction()

    {

    self.resignFirstResponder()

    }

}

how to do validation of a UITextField, while still being edited

If you want to add validation to an instance of UITextField, while editing is still going on, there are a few things you need to do.

Step 1:

Make the viewController adopts UITextFieldDelegate in the class declaration

e.g. class myViewController: UIViewController, UITextFieldDelegate {…}

Step 2:

Set the viewController as the delegate for each of your UITextFields, e.g. in the viewController’s viewDidLoad() function. ‘self’ refers to the viewController.

e.g. myTextField.delegate = self

Step 3:

You need to include the following optional delegate function within your viewController class:

    func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {…}

The important thing to note is that you can’t just check if the UITextField.text is nil or empty when unwrapped, because that won’t work if the UITextField is currently being edited. For that you need to check the UITextField.text + the replacementString.

 

Note: Since UITextField.text can be nil, safer to set a variable using the nil coalescing operator, then concatonate with the string

e.g. let currentTextInTextField = textField.text ?? “”

then you can do your validation against (currentTextInTextField+string)

Step 4:

return false if your validation fails, or true if it succeeds.

iPhone / Apple Watch and EZ-Link, NETS Flashpay

Update to below post: They’ve done it! I can now use my VISA card, and even my Apple Watch or iPhone to pay for trips on the buses and MRT!

The only thing pending that isn’t (officially) supported yet is using my Apple Watch as a Starbucks card…


Since my iPhone reacts when brought near to the NFC (near-field communication) terminal on the bus and brings up the “Pay with Touch ID” screen, I was wondering if you could use your iPhone instead of an EZ-Link or NETS Flashpay card to pay for a bus or train trip.

SMRT and SBS Transit support the EZ-Link and NETS Flashpay contactless cards for payment on buses and trains here in Singapore.

Since a few years ago both Android and iPhone handsets have started to include an NFC chip. I believe that there are android apps that let you use your android phone as an EZ-Link / NETS Flashpay card.

As far as the iPhone is concerned, Apple added some NFC support in iOS11 – it should now be possible to use an iPhone to *read* an NFC card. As far as using an iPhone with an NFC terminal however, they restrict that functionality to only support Apple Pay – that’s why you can’t currently use your iPhone to pay for a trip on the bus or train.

update – I heard that Apple do support the Suica transit card in Japan.

Let’s hope they start extending the support of transit cards to other countries – including Singapore…

-Stuart.

How to add your Starbucks Card to Apple Watch (if ‘Wallet’ isn’t an option)

Even though there’s no Starbucks app for Apple Watch here in Singapore, and no option for adding your Starbucks card to the ‘Wallet’, you can still use your Apple Watch as your Starbucks Card. Here’s how:

  1. open your Starbucks app on the iPhone.
  2. click on ‘Pay’ at the bottom. You will then see a screen showing your card’s barcode
  3. Do a screen-shot by pressing the home button and power button at the same time
  4. Tap on the small image in the bottom left to bring up the image editor
  5. Crop the image to only have the barcode showing, then tap ‘Done’ and chose ‘Save to Photos’.
  6. Open the barcode image in the Photos app. tap on ‘Edit’. Tap on the ‘rotate and crop’ button at the bottom. Then you’ll see a ‘rotate by 90 degrees’ button show up. Tap that twice to rotate the barcode image by 180 degrees.
  7. Tap ‘Done’.
  8. Create a new Album and call it ‘Starbucks’. Add that image to the album.
  9. Open the ‘watch’ app on the iPhone and under ‘Synced Album’ choose ‘Starbucks’. The image will then get copied over to the Apple Watch.
  10. When you want to pay at Starbucks using the watch, open the ‘Photos’ app on the watch. Turn your wrist so that the screen points to the barcode reader and press the crown or touch the screen so that the image shows on the watch.

Update: This has worked for me five times so far, at different outlets. Has only failed once – where the barcode scanner was in an odd position…