Skip to content

Instantly share code, notes, and snippets.

View mnaruse's full-sized avatar
🏠
Working from home

miharu mnaruse

🏠
Working from home
View GitHub Profile
name: Create a release pull request
# https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs#defining-access-for-the-github_token-scopes
permissions:
contents: read
pull-requests: write
jobs:
create-release-pr:
runs-on: ubuntu-latest
# :emoji: Type: Summary
# No more than 50 chars. #### 50 chars is here: #
# Remember blank line between title and body.
# Body: Explain *what* and *why* (not *how*). Include task ID.
# Wrap at 72 chars. ################################## which is here: #
# At the end: Include Co-authored-by for all contributors.
# Include at least one empty line before it. Format:
@mnaruse
mnaruse / IDETemplateMacros.plist
Last active August 14, 2023 12:08
Where? Workspace shared data: [WorkspaceName].xcworkspace/xcshareddata/IDETemplateMacros.plist, User Xcode data: ~/Library/Developer/Xcode/UserData/IDETemplateMacros.plist
<?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>FILEHEADER</key>
<string>
// ___FILENAME___
// ___TARGETNAME___
//
// Created by ___USERNAME___ on ___DATE___
@mnaruse
mnaruse / ViewController+ToolBar.swift
Last active November 19, 2020 10:23
対象のテキストフィールドがアクティブなとき、キーボードのツールバーに、前後ボタンや完了ボタンを設定するExtension。
//
// ViewController+ToolBar.swift
// KeyboardUpDownSample
//
// Created by Miharu Naruse on 2020/11/15.
//
// 参考元サイト
// - URL:: https://stackoverflow.com/questions/14148276/toolbar-with-previous-and-next-for-keyboard-inputaccessoryview
@mnaruse
mnaruse / NSLocationDefaultAccuracyReduced.xml
Created July 8, 2020 20:16
WWDC20: What's new in location.
// iOS14
// Info.plist
<key>NSLocationDefaultAccuracyReduced</key>
<true/>
@mnaruse
mnaruse / kCLLocationAccuracyReduced.swift
Created July 8, 2020 20:15
WWDC20: What's new in location.
// iOS14
// Reduces accuracy by default
var locationManager = CLLocationManager()
locationManager.desiredAccuracy = kCLLocationAccuracyReduced
// iOS14
// Asking for full accuracy
// Purpose keys in Info.plist
<key>NSLocationTemporaryUsageDesriptionDictionary</key>
<dict>
<key>WantsToNavigate</key>
<string>Your precise location will be used to calculate a route and allow you to use turn-by-turn directions.</string>
<key>TacoFeature</key>
<string>Your precise location will be used to deliver tacos to you.</string>
// iOS14
// Asking for full accuracy
// Purpose keys in Info.plist
<key>NSLocationTemporaryUsageDesriptionDictionary</key>
<dict>
<key>WantsToNavigate</key>
<string>Your precise location will be used to calculate a route and allow you to use turn-by-turn directions.</string>
<key>TacoFeature</key>
<string>Your precise location will be used to deliver tacos to you.</string>
// iOS14
// プロンプトを表示し、一時的な位置精度のアップグレードを依頼する(アプリを閉じない限り有効)。
// なぜ正確な位置情報が必要なのか、明確に説明する文字列を表示するために、
// Info.plist の NSLocationTemporaryUsageDescriptionDictionary をキーにした辞書に、目的キーを追加しなければならない。
@IBAction func userWantsToNavigate(_ sender: Any) {
// It looks like the user wants to navigate!
if manager.accuracyAuthorization == .reducedAccuracy {
manager.requestTemporaryFullAccuracyAuthorization(withPurposeKey: "WantsToNavigate") {
if self.manager.accuracyAuthorization == .fullAccuracy {
// iOS14
// 新しいデリゲート・コールバック・メソッドを実装する方法を以下に示します。
// どのように進めるかを決定するには、authorizationStatus と accuracyAuthorization の両方の値を確認する必要があります。
func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {
switch manager.authorizationStatus {
case .authorizedAlways, .authorizedWhenInUse:
self.hasSomeKindOfPermission = true
case .notDetermined, .denied, .restricted:
self.hasSomeKindOfPermission = false