This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// BinarySearch.m | |
// KIObjcAlgorithms | |
// | |
// Created by Keita on 9/8/15. | |
// Copyright (c) 2015 Keita Ito. All rights reserved. | |
// | |
#import "BinarySearch.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// SelectionSort.m | |
// KIObjcAlgorithms | |
// | |
// Created by Keita on 9/11/15. | |
// Copyright © 2015 Keita Ito. All rights reserved. | |
// | |
#import "SelectionSort.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Archvier<T: AnyObject> { | |
static func getStringOfClassName(object: T) -> String { | |
return String(T) | |
} | |
} | |
// NSStringFromClass() didn't work with my custom class, even it is a subclass of NSObject. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Prepare address values. These values will be saved in a record in iPhone's address book. | |
NSString *city = @"Yokohama"; | |
NSString *state = @"Kanagawa" | |
NSString *country = @"Japan"; | |
// Get a record ID. | |
ABRecordID recordID = self.recordID; // Assume you have a recordID. | |
// Create dictionary for address. | |
ABMutableMultiValueRef address = ABMultiValueCreateMutable(kABMultiDictionaryPropertyType); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (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)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// NSCoding Protocol conformed implementation | |
// Reference: http://stackoverflow.com/questions/20539619/storing-custom-objects-with-core-data | |
import Foundation | |
class MyClass: NSObject, NSCoding { | |
let name: String | |
init(name: String) { | |
self.name = name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: Playground - noun: a place where people can play | |
import UIKit | |
import XCPlayground | |
class SomeView: UIView { | |
override init(frame: CGRect) { | |
super.init(frame: frame) | |
let button = UIButton(frame: self.bounds) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: Playground - noun: a place where people can play | |
let tuples = [("A", "あ"), ("I", "い"), ("U", "う"), ("E", "え"), ("O", "お")] | |
print("With argument list") | |
tuples.forEach { (eng, jpn) in | |
print(eng) | |
print(jpn) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
******************** | |
Testing Time: 815.15s | |
******************** | |
Failing Tests (346): | |
Swift(macosx-x86_64) :: SILOptimizer/specialize_partial_apply.swift | |
Swift(macosx-x86_64) :: SILOptimizer/let_properties_opts_runtime.swift | |
Swift(macosx-x86_64) :: SILOptimizer/capture_propagation_linkage.swift | |
Swift(macosx-x86_64) :: stdlib/BridgeIdAsAny.swift.gyb | |
Swift(macosx-x86_64) :: multifile/error-type/two-modules/main.swift | |
Swift(macosx-x86_64) :: multifile/synthesized-accessors/one-module-public/main.swift |
OlderNewer