Skip to content

Instantly share code, notes, and snippets.

@coreyjv
coreyjv / NSOperation_ApiClient_Playground.swift
Created December 14, 2015 03:44
This shows an example of how we could use NSOperation as a return from our ApiClient which can be easily used by the UI to pass a completion block and asynchronously trigger
import Foundation
import XCPlayground
class ImageDownloader: NSOperation {
let imageId: String
var data: String?
init(imageId: String) {
self.imageId = imageId
}
@coreyjv
coreyjv / NullEmptyStringDemo.java
Created November 19, 2015 01:21
Handling empty and nil Strings in Swift compared to Java
public class NullEmptyStringDemo {
public static void main(String[] args) {
ApiClient apiClient = new ApiClient();
// throws IllegalArgumentException, but note that we don't have to catch it
apiClient.getItemAsync("", "");
}
public static class ApiClient {
// Simulate a similar call in ApiClient