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
import Foundation | |
let str: NSString = NSString(string: "Charlie Brown") | |
let a:NSRange = str.rangeOfString("Brown") | |
print(a.location) | |
print(a.length) | |
print(NSNotFound) | |
var ar: NSArray | |
do { | |
let reg: NSRegularExpression = try NSRegularExpression(pattern: "Brown", |
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
// 本文ラベルを取得して、本文を設定する | |
let descriptionLabel = cell!.viewWithTag(2) as! UILabel | |
let htmlString = entry["contentSnippet"] as? String | |
do { | |
let astr = | |
try NSAttributedString(data: | |
htmlString!.dataUsingEncoding(NSUnicodeStringEncoding)!, | |
options: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType], | |
documentAttributes: nil) | |
descriptionLabel.text = astr.string |
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
MDATE | OPEN | HIGH | LOW | CLOSE | VOLUME | |
---|---|---|---|---|---|---|
1987/8/1 | 24755 | 24755 | 24755 | 24755 | 0 | |
1987/8/3 | 24483 | 24483 | 24483 | 24483 | 0 | |
1987/8/4 | 24172 | 24172 | 24172 | 24172 | 0 | |
1987/8/5 | 24297 | 24297 | 24297 | 24297 | 0 | |
1987/8/6 | 24658 | 24658 | 24658 | 24658 | 0 | |
1987/8/7 | 24800 | 24800 | 24800 | 24800 | 0 | |
1987/8/10 | 25119 | 25119 | 25119 | 25119 | 0 | |
1987/8/11 | 25282 | 25282 | 25282 | 25282 | 0 | |
1987/8/12 | 25560 | 25560 | 25560 | 25560 | 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
grepをリカーシブに実行するためのメモ | |
grep -r --include "*.swift" NSSearch . | |
find . -name "*.swift" | xargs grep NSSearch |
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
わりと何度もこの問題にはぶつかっていて、 | |
tableView.delaysContentTouches = false | |
だよね。と思っていたんだけど、今回はこれだけではダメだった。 | |
解決した方法 | |
tableView.delaysContentTouches = false | |
for case let v as UIScrollView in tableView.subviews { | |
v.delaysContentTouches = false | |
} |
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
●Swiftでの2つの参照値が参照している2つのインスタンスの中身(値)の比較:== | |
例:let a = ..., let b = ..., if a == b {...} | |
●Swiftでの参照値が同一のオブジェクトを参照しているかの判定(比較):=== | |
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
import Foundation | |
var hex = "ABCDEF" | |
// remove space located at header, trailer | |
let cString:String = hex.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet()).uppercaseString | |
//whitespaceAndNewlineCharacterSet, space, linefeed | |
if ((cString as String).characters.count != 6) { | |
print("Error") | |
} | |
// picking up 2 chars |
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
enum List<T> { | |
case Cons(T, () -> List<T>) | |
case Nil | |
} | |
// list構造はlist要素が連なったものである。list要素はenumで定義する。 | |
// list構造は、cons関数で作る。リスト構造もリスト要素である。 | |
// リスト要素は、ConsまたはNil。Cons(T,(Function))、タプルを要素にする。 | |
// Cons関数の様に見えるが、タプルを内包している。 | |
func cons<T>(value: T, _ list: List<T>) -> List<T> { | |
return List.Cons(value) { list } |
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
class Person { | |
var friend: Person? = nil | |
} | |
let a = Person() // aオブジェクトの参照カウントは1 | |
let b = Person() | |
a.friend = b | |
b.friend = a // aオブジェクトの参照カウントは2 | |
a = nil | |
b = nil | |
// ここでメモリリークが発生。friendプロパティーはオブジェクトを参照しているため、オブジェクトの参照カウントは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
掲題のページを参考に作業する際の注意点 | |
1. Swift1.x系統 | |
2. Attribute Inspectorでsize = Freeformを指定 | |
3. @IBOutlet, @IAOutletを適切に設定しないと | |
fatal error: unexpectedly found nil while unwrapping an Optional value | |
(lldb) | |
で落ちる。 |
OlderNewer