Skip to content

Instantly share code, notes, and snippets.

View keitaito's full-sized avatar

Keita Ito keitaito

View GitHub Profile
@keitaito
keitaito / ReadAndWritePlistFile.m
Last active April 28, 2021 14:51
Read and Write Plist File in Objective-C, converted from Swift version written by Rebeloper http://rebeloper.com/read-write-plist-file-swift/
//
// ViewController.m
// ReadAndWritePlistFile
//
// Created by Keita on 3/3/15.
// Copyright (c) 2015 Keita Ito. All rights reserved.
// converted from Swift version written by Rebeloper http://rebeloper.com/read-write-plist-file-swift/
#import "ViewController.h"
@keitaito
keitaito / GetValueFromCFDictionaryRef.m
Created March 9, 2016 08:45
Get value from CFDictionaryRef by converting it to NSDictionary.
+ (NSString *)getValueFromCFDictionaryRef {
// Assume you have record ID.
NSInteger recordID;
// Get a person record.
ABAddressBookRef addressBook = ABAddressBookCreate();
ABRecordRef person = ABAddressBookGetPersonWithRecordID(addressBook, recordID);
// Get addresses data from person. Watch out it's a multi-value property.
ABMultiValueRef addresses = ABRecordCopyValue(person, kABPersonAddressProperty);
// Get the first one. Convert it from CFDictionaryRef to NSDictionary.
NSDictionary *address = (NSDictionary *)CFBridgingRelease(ABMultiValueCopyValueAtIndex(addresses, 0));
@keitaito
keitaito / cocoapods-rainforest-rake-bootstrap-log
Created February 1, 2017 23:26
The log of Cocoapods/Rainforest `rake bootstrap` command
Last login: Sun Jan 29 14:33:59 on ttys003
Keitas-MacBook:~ keitaito$ cd /Users/keitaito/dev/Xcode/Repos/Clones/Rainforest
Keitas-MacBook:Rainforest keitaito$
Keitas-MacBook:Rainforest keitaito$
Keitas-MacBook:Rainforest keitaito$
Keitas-MacBook:Rainforest keitaito$ rake bootstrap
/Users/keitaito/.rbenv/versions/2.3.2/bin/bundle
--------------------------------------------------------------------------------
Fetching repositories list
//
// HackerRankChallengeSolution-Kangaroo.swift
// Kangaroo
//
// Created by Keita Ito on 1/29/17.
// Copyright © 2017 Keita Ito. All rights reserved.
//
// https://www.hackerrank.com/challenges/kangaroo
//
// main.swift
// DesignerPDFViewer
//
// Created by Keita Ito on 1/26/17.
// Copyright © 2017 Keita Ito. All rights reserved.
//
// The link to the challenge: https://www.hackerrank.com/challenges/designer-pdf-viewer
@keitaito
keitaito / HackerRankSolutionForTheLoveLetterMystery.swift
Last active January 19, 2017 07:43
Solution for The Love Letter Mystery in HackerRank
// https://www.hackerrank.com/challenges/the-love-letter-mystery
let t = Int(readLine()!)!
var inputs = [String]()
for i in 0..<t {
let string = readLine()!
inputs.append(string)
}
// Add Foundation import to be able to use NSDate class below.
import Foundation
print("Hello, world!")
// There is always one argument passed, which is the name of the program,
// that is the file name.
if CommandLine.argc < 2 {
print("No arguments are passed.")
let firstArgument = CommandLine.arguments[0]
// Add Foundation import to be able to use NSDate class below.
import Foundation
print("Hello, world!")
// There is always one argument passed, which is the name of the program,
// that is the file name.
if CommandLine.argc < 2 {
print("No arguments are passed.")
let firstArgument = CommandLine.arguments[0]
print("Hello, world!")
// There is always one argument passed, which is the name of the program,
// that is the file name.
if CommandLine.argc < 2 {
print("No arguments are passed.")
let firstArgument = CommandLine.arguments[0]
print(firstArgument)
} else {
print("Arguments are passed.")
// Add Foundation import to be able to use NSDate class below.
import Foundation
print("Hello, world!")
// There is always one argument passed, which is the name of the program,
// that is the file name.
if CommandLine.argc < 2 {
print("No arguments are passed.")
let firstArgument = CommandLine.arguments[0]