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 object: AnyObject = objects[row] | |
| if let object = object as? Level { | |
| return object.name | |
| } | |
| if let object = object as? Power { | |
| return object.name | |
| } | |
| if let object = object as? Status { | |
| return object.name | |
| } |
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 model: aType? | |
| var status: aType? | |
| if let model = model { | |
| if let status = status { | |
| model.status.doSomething() | |
| } | |
| } | |
| or its better to do this: |
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
| println(json["created_at"].stringValue) | |
| let dateFormatter = NSDateFormatter() | |
| /* created_at: "2014-12-17 11:06:09" " */ | |
| dateFormatter.dateFormat = "YYYY-MM-DD HH:mm:ss" | |
| var date = dateFormatter.dateFromString(json["created_at"].stringValue) | |
| println(date) | |
| 2014-12-17 11:06:09 | |
| Optional(2014-01-17 10:06:09 +0000) |
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 coreDataMessage: Message = Message(entity: messageEntitiy!, insertIntoManagedObjectContext: Model.managedObjectContext) | |
| coreDataMessage.friend = friend | |
| println("The username \(friend.username)") // 1 | |
| coreDataMessage.duration = 12 | |
| var error: NSError? | |
| Model.managedObjectContext.save(&error) | |
| println("Error \(error)") // 2 | |
| let request = NSFetchRequest(entityName: "Message") | |
| let messages = Model.managedObjectContext.executeFetchRequest(request, error: nil) as [Message] |
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
| NSNotificationCenter.defaultCenter().postNotificationName("allowPlaying", object: nil, userInfo: ["allowPlaying":false]) | |
| func allowPlaying(notification: NSNotification) { | |
| let userInfo = notification.userInfo as [String: Int] | |
| let allowPlaying = (userInfo["allowPlaying"] as Int).boolValue //Error Int doesnt have a member named boolValue | |
| } |
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 ParseUser: PFUser, PFSubclassing { | |
| override class func load() { | |
| self.registerSubclass() | |
| } | |
| @NSManaged var photo: PFFile! | |
| @NSManaged var displayName: String! | |
| @NSManaged var categories: [String]! | |
| @NSManaged var isBroadcaster: NSNumber! |
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
| extension ParseUser { | |
| var numberOfFollowers = Model.countNumberOfFollowers(user: self) { (count: Int) in return count } | |
| } | |
| class func countNumberOfFollowers(#user: ParseUser!, completion:((count: Int!) -> ())) { | |
| var fromQuery = ParseFriend.query() | |
| fromQuery.whereKey("toUser", equalTo: user) | |
| let toQuery = ParseFriend.query() | |
| toQuery.whereKey("fromUser", equalTo: user) | |
| let orQuery = PFQuery.orQueryWithSubqueries([fromQuery, toQuery]) |
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
| enum EffectMode: Int { | |
| case noEffect = 0, darthVader, helium, snail, rocket | |
| } | |
| var effect: EffectMode! | |
| func duration() -> NSTimeInterval { | |
| switch(effect) { | |
| case .snail: |
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
| ~/Library/Developer/CoreSimulator/Devices/04CCC39A-138E-4463-A574-2DCC98DBBBF6/data/Containers/Data/Application/1DE679F5-31F6-492C-94CF-421B10165374/Library$ ls -la | |
| total 16 | |
| drwxr-xr-x 6 ivanruizmonjo admin 204 Jan 11 00:21 . | |
| drwxr-xr-x 7 ivanruizmonjo admin 238 Jan 11 00:21 .. | |
| -rw-r--r--@ 1 ivanruizmonjo admin 6148 Jan 11 00:21 .DS_Store | |
| drwxr-xr-x 5 ivanruizmonjo admin 170 Jan 10 23:05 Caches | |
| drwxr-xr-x 3 ivanruizmonjo admin 102 Jan 10 23:05 Preferences | |
| drwxr-xr-x 3 ivanruizmonjo admin 102 Jan 10 23:05 Private Documents | |
| ~/Library/Developer/CoreSimulator/Devices/04CCC39A-138E-4463-A574-2DCC98DBBBF6/data/Containers/Data/Application/1DE679F5- |
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 audioFile: AVAudioFile! | |
| var path: AnyObject = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentationDirectory, NSSearchPathDomainMask.UserDomainMask, true)[0] | |
| path = path.stringByAppendingPathComponent("audio.caf") | |
| data.writeToURL(NSURL.fileURLWithPath(path as String)!, atomically: true) | |
| //data.writeToFile(documents as String, atomically: true) | |
| var audioFileError: NSError? |