Skip to content

Instantly share code, notes, and snippets.

View rileytestut's full-sized avatar

Riley Testut rileytestut

View GitHub Profile
@rileytestut
rileytestut / ExportIPA.swift
Last active March 4, 2024 09:36
Export Swift Playgrounds .ipa
import Foundation
// Export running app as .ipa, then return path to exported file.
// Returns String because app crashes when returning URL from async function for some reason...
func exportIPA() async throws -> String
{
// Path to app bundle
let bundleURL = Bundle.main.bundleURL
// Create Payload/ directory
@rileytestut
rileytestut / tuple.swift
Created June 23, 2016 21:14
Swift Tuple Casting
import Foundation
let string1: NSObject = NSString(string: "string1")
let string2: NSObject = NSString(string: "string2")
if let result = (string1, string2) as? (NSString, NSString)
{
print(result)
}
else
@rileytestut
rileytestut / playground.swift
Created June 23, 2016 18:35
Type Inference Crash
import Foundation
import UIKit
// If defined here in the same module, no issue
// However, if defined in a separate module + used, will cause compiler crash
// public typealias GenericResult<T> = Result<T, NSError>
func testFunction<T>(withCompletion completion: (Result<T, NSError>) -> Void)
{
//: Playground - noun: a place where people can play
import Foundation
enum GameSystemIdentifier
{
case Wii
case Xbox
case PlayStation
}

Keybase proof

I hereby claim:

  • I am rileytestut on github.
  • I am rileytestut (https://keybase.io/rileytestut) on keybase.
  • I have a public key whose fingerprint is 9F48 110A 2CAD 6894 C311 8C59 6193 4DFC 268A 7C71

To claim this, I am signing this object:

@rileytestut
rileytestut / gist:6245198
Created August 15, 2013 21:37
RSTWebViewControllerDownloadDelegate Protocol
@protocol RSTWebViewControllerDownloadDelegate <NSObject>
@optional
// Return YES to tell RSTWebViewController to create a [Redacted] object and start a [Redacted]DownloadTask.
// Or, if you choose to, you can return NO, and then implement your own downloading logic via [Redacted] with the NSURLRequest
- (BOOL)webViewController:(RSTWebViewController *)webViewController shouldStartDownloadWithRequest:(NSURLRequest *)request;
// If implemented, you must call startDownloadBlock, or else the download will never start. This was you can display an alert to the user asking if they want to download the file.
// If needed, you can keep a reference to the [Redacted]DownloadTask to suspend/cancel during the download. You can access the original request via downloadTask.originalRequest, or the current one via downloadTask.currentRequest