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
| static NSData *PSPDFCalculateSHA256FromFileURL(NSURL *fileURL, CC_LONG dataLength, NSError **error) { | |
| NSCParameterAssert(fileURL); | |
| dispatch_queue_t shaQueue = dispatch_queue_create("com.pspdfkit.sha256-queue", DISPATCH_QUEUE_SERIAL); | |
| __block dispatch_io_t readChannel; | |
| void (^processIntError)(int intError) = ^(int intError) { | |
| if (intError != 0) { | |
| PSPDFLogWarning(@"Stream error: %d", intError); | |
| if (error) *error = [NSError errorWithDomain:@"SHA256Error" code:100 userInfo:@{NSLocalizedDescriptionKey: @"failed to open file for calculating SHA256."}]; |
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
| static NSData *PSPDFCalculateSHA256FromFileURL(NSURL *fileURL, CC_LONG dataLength, NSError **error) { | |
| NSCParameterAssert(fileURL); | |
| NSData *shaData; | |
| int fd = open(fileURL.path.UTF8String, O_RDONLY); | |
| if (fd < 0) { | |
| if (error) *error = [NSError pspdf_errorWithCode:PSPDFErrorCodeUnableToOpenPDF description:@"Failed to open file for calculating SHA256."]; | |
| return nil; | |
| } |
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
| //disable TOC button | |
| window.HelpViewer.showTOCButton(false); | |
| //enable TOC button | |
| //If you call this on window load it will flash active for a brief second and then disable again. | |
| //Call if after a delay of 250ms and is works fine | |
| //Not sure what the second variable does yet, but passing false works fine | |
| window.HelpViewer.showTOCButton( true, false, function() { | |
| //do something to toggle TOC in your webpage | |
| }); |
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
| // | |
| // DON'T do this, or else you risk a deadlock (e.g., by accidentally performing it in a different order somewhere) | |
| // | |
| dispatch_async(firstQueue, ^{ | |
| dispatch_sync(secondQueue, ^{ | |
| // code requiring both queues | |
| }); | |
| }); |
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
| #!/bin/bash | |
| # | |
| # Faster toolchain build: skips as much as possible. | |
| # | |
| # To use this toolchain from the command line:" | |
| # export TOOLCHAINS=$(whoami) | |
| # | |
| # we build to the same prefix every time (instead of building | |
| # to a versioned prefix) because every time the prefix changes | |
| # *everything* rebuilds. |
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 Dispatch | |
| import Foundation | |
| var x = 7 | |
| let dd = withUnsafeBytes(of: &x, { DispatchData.init(bytes: $0) }) | |
| print(dd as? Data) // Case 1: nil | |
| print(dd as? NSData) // Case 2: nil | |
| print(dd as Any as? Data) // Case 3: nil | |
| print(dd as Any as? NSData) // Case 4: .some | |
| print(dd as Any as? NSData as Data?) // Case 5: .some |
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 UIKit | |
| /// A wrapper view controller that makes the horizontal size class | |
| /// be based on both the Dynamic Text size and the width available. | |
| class AdaptiveTraitsContainer: UIViewController { | |
| let wrappedViewController: UIViewController | |
| init(wrappedViewController: UIViewController) { | |
| self.wrappedViewController = wrappedViewController | |
| super.init(nibName: nil, bundle: nil) |
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
| public typealias LosslessStringCodable = LosslessStringConvertible & Codable | |
| @propertyWrapper | |
| public struct LosslessCodable<Value: LosslessStringCodable>: Codable { | |
| private let type: LosslessStringCodable.Type | |
| public var wrappedValue: Value | |
| public init(wrappedValue: Value) { | |
| self.wrappedValue = wrappedValue |
OlderNewer