Skip to content

Instantly share code, notes, and snippets.

@MylesCaley
MylesCaley / blink-cursor.swift
Created March 15, 2017 20:40
blink cursor in textfield without showing keyboard
@MylesCaley
MylesCaley / get datasource element.swift
Created April 17, 2017 15:29
RxDataSources - get data
func collectionView(_ collectionView: UICollectionView, heightForAnnotationAtIndexPath indexPath: IndexPath, withWidth width: CGFloat) -> CGFloat {
let x = dataSource?[indexPath]
let font = UIFont(name: "OpenSans", size: 11)!
let rect = NSString(string: x?.brief ?? "").boundingRect(with: CGSize(width: width, height: CGFloat(MAXFLOAT)), options: .usesLineFragmentOrigin, attributes: [NSFontAttributeName: font], context: nil)
// if multiple types
//this takes a list of items in an array, then runs an observable on each of them, finally it combines
//all of the outputs into one observable which returns all of the media items at once
Observable.combineLatest(mediaItems.map({ $0.getMediaMetadataObservable() })).subscribe(onNext: { a in
for item in a {
print (item.type)
}
})