This file contains hidden or 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
var a = (price: 180, no: 32) | |
var b = (no: 0, price: 10) | |
b = a // b = (no:32, price: 180) になる | |
if a == b { | |
print("実行されない") | |
} |
This file contains hidden or 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
// | |
// FavoritesViewController.swift | |
// | |
// Created by kishikawakatsumi on 3/12/16. | |
// Copyright © 2016 Realm. All rights reserved. | |
// | |
import UIKit | |
import RealmSwift |
This file contains hidden or 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
dispatch_async(dispatch_get_main_queue()) { | |
self.refreshControl?.endRefreshing() | |
} |
This file contains hidden or 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
override func viewDidLoad() { | |
// 略 | |
refreshControl?.addTarget(self, action: #selector(TimelineViewController.refresh(_:)), forControlEvents: .ValueChanged) | |
} | |
func refresh(sender: UIRefreshControl) { | |
if let _ = self.account { | |
getHomeTimeline() |
This file contains hidden or 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 UIKit | |
import Accounts | |
import Social | |
import RealmSwift | |
class TimelineViewController: UITableViewController { | |
var timeline: Results<Tweet>? | |
var notificationToken: NotificationToken? |
This file contains hidden or 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 TimelineViewController: UITableViewController { | |
// 中略 | |
override func numberOfSectionsInTableView(tableView: UITableView) -> Int { | |
return 1 | |
} | |
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
return timeline?.count ?? 0 |
This file contains hidden or 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 TimelineViewController: UITableViewController { | |
var timeline: Results<Tweet>? | |
var notificationToken: NotificationToken? | |
var account: ACAccount? | |
override func viewDidLoad() { | |
super.viewDidLoad() |
This file contains hidden or 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 TimelineViewController: UITableViewController { | |
var account: ACAccount? | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
let accountStore = ACAccountStore() | |
let accountType = accountStore.accountTypeWithAccountTypeIdentifier(ACAccountTypeIdentifierTwitter) | |
accountStore.requestAccessToAccountsWithType(accountType, options: nil) { (granted, error) -> Void in |
This file contains hidden or 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
override func viewDidLoad() { | |
super.viewDidLoad() | |
let accountStore = ACAccountStore() | |
let accountType = accountStore.accountTypeWithAccountTypeIdentifier(ACAccountTypeIdentifierTwitter) | |
accountStore.requestAccessToAccountsWithType(accountType, options: nil) { (granted, error) -> Void in | |
if granted { | |
let accounts = accountStore.accountsWithAccountType(accountType) | |
if let account = accounts.first as? ACAccount { | |
self.account = account |
This file contains hidden or 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 requestURL = NSURL(string: "https://api.twitter.com/1/statuses/home_timeline.json") | |
let request = SLRequest(forServiceType: SLServiceTypeTwitter, requestMethod: .GET, URL: requestURL, parameters: nil) | |
request.account = account |