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
NSPredicate *predicate = [[EKEventStore new] predicateForEventsWithStartDate:startDate | |
endDate:endDate | |
calendars:calendars]; | |
NSArray *events = [[EKEventStore new] eventsMatchingPredicate:predicate]; |
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 AVFoundation |
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 queuePlayer = AVQueuePlayer() |
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 urlPath = NSBundle.mainBundle().pathForResource("your_file", ofType:"mp3") | |
let fileURL = NSURL(fileURLWithPath:urlPath!) | |
let playerItem = AVPlayerItem(URL:fileURL) | |
queuePlayer.insertItem(playerItem, afterItem:nil) |
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
queuePlayer.play() | |
queuePlayer.pause() | |
queuePlayer.removeItem(queuePlayer.currentItem) // skip current audio |
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 | |
class Event : NSObject, NSCoding { | |
var name : String? | |
var details : String? | |
var date : NSDate? | |
init(name : String, details : String, date : NSDate) { | |
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
@IBAction func buttonAction() { | |
let dictionary = ["message": "Hi, apple watch here!"] | |
WKInterfaceController.openParentApplication(dictionary) { | |
(replyInfo, error) -> Void in | |
let reply = replyInfo["event"] as! NSData // take our encoded event from dictionary | |
NSKeyedUnarchiver.setClass(Event.self, forClassName: "Event") // We are not using original class anymore, so we have to do it | |
let event = NSKeyedUnarchiver.unarchiveObjectWithData(reply) // decode the event | |
} |
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
func application(application: UIApplication, handleWatchKitExtensionRequest userInfo: [NSObject : AnyObject]?, reply: ([NSObject : AnyObject]?) -> Void) { | |
let message = userInfo?["message"] as! String // we can get a message, that we sent from watch | |
let event = Event(name: "test", details: "test", date:NSDate()) // create our Event object | |
NSKeyedArchiver.setClassName("Event", forClass: Event.self) // We are using 'different' classes on watch and iPhone, so we have to do it | |
let archivedEvent = NSKeyedArchiver.archivedDataWithRootObject(event) // archive the Event | |
let dictionary = ["event" : archivedEvent] // creating dictionary with our NSData | |
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
func application(application: UIApplication, handleWatchKitExtensionRequest userInfo: [NSObject : AnyObject]?, reply: ([NSObject : AnyObject]?) -> Void) { | |
let message = userInfo?["message"] as! String | |
let event = Event(name: "test", details: "test", date:NSDate()) | |
NSKeyedArchiver.setClassName("Event", forClass: Event.self) | |
NSKeyedArchiver.archivedDataWithRootObject(event) | |
let dictionary = ["event" : event] | |
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
public private(set) lazy var imageView: UIImageView = { | |
let imageView = UIImageView() | |
imageView.layer.cornerRadius = Dimensions.imageSize / 2 | |
imageView.clipsToBounds = true | |
imageView.contentMode = .ScaleAspectFill | |
return imageView | |
}() |