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 |
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 account: ACAccount? | |
override func 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
import UIKit | |
class TimelineCell: UITableViewCell { | |
@IBOutlet weak var iconView: UIImageView! | |
@IBOutlet weak var nameLabel: UILabel! | |
@IBOutlet weak var tweetTextView: UITextView! | |
override func prepareForReuse() { | |
iconView.image = nil | |
nameLabel.text = nil |
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 Foundation | |
import RealmSwift | |
class Tweet: Object { | |
dynamic var name = "" | |
dynamic var text = "" | |
dynamic var iconURL = "" | |
dynamic var id = "" | |
dynamic var createdAt = NSDate() |
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
static var dateFormatter: NSDateFormatter { | |
let dateFormatter = NSDateFormatter() | |
dateFormatter.locale = NSLocale(localeIdentifier: "en_US_POSIX") | |
dateFormatter.dateFormat = "EEE MMM dd HH:mm:ss Z yyyy" | |
return dateFormatter | |
} | |
convenience init(tweetDictionary: [String: AnyObject]) { | |
self.init() | |
let user = tweetDictionary["user"] as! [String: AnyObject] |
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 RealmSwift | |
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? | |
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { |
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 Foundation | |
import RealmSwift | |
class Tweet: Object { | |
dynamic var name = "" | |
dynamic var text = "" | |
dynamic var iconURL = "" | |
dynamic var id = "" | |
dynamic var createdAt = NSDate() | |
} |
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 RealmSwift | |
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? | |
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { |
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 foo: NSDate? = NSDate() | |
let interval: NSTimeInterval = 1.0 | |
let bar: String = "" | |
// Mark - | |
// Mapで出来るぞ | |
if foo.map({$0.timeIntervalSinceNow < interval}) ?? bar.isEmpty { | |
print("load") | |
} |
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 string1 = "" // これが isEmpty なら | |
let string2: String? = nil // nil の時でも | |
if let s = string2 where s == "string" || string1.isEmpty { | |
print("load") // 実行されたい | |
} | |
// こんな書き方はできないけどイメージはこれ if (let where ) || ... |