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 SwiftUI | |
extension String { | |
func width(using font: UIFont) -> CGFloat { | |
let fontAttributes = [NSAttributedString.Key.font: font] | |
let size = self.size(withAttributes: fontAttributes) | |
return size.width | |
} | |
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
final class MovieImport: Migration { | |
typealias Database = SQLiteDatabase | |
static func prepare(on conn: SQLiteConnection) -> EventLoopFuture<Void> { | |
MovieDatabase.shared.populateFromCSV(connection: conn) | |
return conn.eventLoop.newPromise(of: Void.self).futureResult // Is this correct? | |
} | |
static func revert(on conn: SQLiteConnection) -> EventLoopFuture<Void> { |
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
// I have one table: Movie. To add records, after the Movie migration I’m doing: | |
let worker = MultiThreadedEventLoopGroup(numberOfThreads: 1) | |
let conn = sqliteDatabase.newConnection(on: worker) | |
let _ = conn.map { connection in | |
// Open the CSV file | |
for line in lines { | |
// Parse the line to get the title, etc. | |
let movie = Movie(id: id, title: title) | |
dispatchGroup.enter() | |
let future = movie.save(on: connection) |
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
version: 2 | |
jobs: | |
build: | |
macos: | |
xcode: "9.4.0" | |
# The rest of our build job | |
snapshots: | |
macos: | |
xcode: "9.4.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
UISearchController *searchController = [[UISearchController alloc] initWithSearchResultsController:nil]; | |
self.navigationItem.searchController = searchController; | |
self.definesPresentationContext = YES; | |
searchController.obscuresBackgroundDuringPresentation = NO; | |
self.navigationItem.searchController.searchBar.placeholder = NSLocalizedString(@"Search", @"search bar placeholder text. typing into this search field filters the content below"); | |
self.navigationItem.searchController.searchResultsUpdater = self; |
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 | |
protocol MyProtocol { | |
func foo() | |
} | |
class Parent { | |
func foo() { | |
print("parent") | |
} |
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
protocol MyProtocol { | |
func method() -> String | |
} | |
extension MyProtocol { | |
func method() -> String { | |
return "foo" | |
} | |
} |
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
AMPSession *session = [AMPSession ampSessionWithSessionAndProfileInfo:sessionAndProfileInfo]; | |
[[session podcastWithId:@(contentID)] done:^(AMPv3Podcast *ampPodcast) { | |
NSLog(@"session: %@", session); | |
} rejected:^(NSError *error) { | |
if (completionHandler) { | |
completionHandler(nil, error); | |
} | |
}]; |
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
AMPTalkService *talkService = [AMPTalkService new]; | |
[talkService addTalkRadioWithCotentID:showID | |
contentType:AMPRadioServiceContentTypeShow | |
addToFavorites:NO | |
sessionAndProfileInfo:sessionAndProfileInfo | |
completionHandler:^(CustomTalkRadio *radio, NSError *error) { | |
if (error) { | |
[self handleDidFailWithError:error]; | |
return; | |
} |
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
// before the change | |
BAPromise *promise = [self methodThatReturnsAPromise]; | |
[promise then:^id(id obj) { | |
NSLog(@"1st"); | |
return [[self otherMethodThatReturnsAPromise] then:^id(id obj) { | |
NSLog(@"2nd"); | |
return obj; | |
}]; | |
}]; |
NewerOlder