- http://useyourloaf.com/blog/slow-app-startup-times/
- Add DYLD_PRINT_STATISTICS to print out pre-main load time
- http://stackoverflow.com/questions/31080284/adding-several-pods-increases-ios-app-launch-time-by-10-seconds
- artsy/eigen#586
- https://engineering.tumblr.com/post/144507330193/peeking-into-a-black-box-the-effect-of
- "This is an issue in production, but is even more critical for our internal enterprise builds, which can take so long to launch that the OS terminates them."
- "Because the numbers do not bear this out, we conclude that the structure of the dependency graph does not affect launch time."
- https://twitter.com/sozorogami/status/792421991592648705
This file contains 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 | |
FILES=~/Path/To/Folder/With/Files | |
for f in $FILES | |
do | |
echo "Processing $f file..." | |
# take action on each file. $f stores current file name. | |
ed -s $f <<< w | |
done |
This file contains 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
/// After using `requestAuthorizationToShareTypes:readTypes:completion:` | |
- (BOOL)hasRequestedHeartRateAuthorization | |
{ | |
return (HKAuthorizationStatusNotDetermined != [HKHealthStore authorizationStatusForType:[HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierHeartRate]]); | |
} | |
- (void)requestHeartRateAuthorizationWithCompletion:(void (^)(BOOL succes, NSError *error))completion | |
{ | |
NSSet *readTypes = [NSSet setWithObject:[HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierHeartRate]]; | |
[self.store requestAuthorizationToShareTypes:nil readTypes:readTypes completion:^(BOOL success, NSError *error){ |
This file contains 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
- (void)hasMotionAndFitnessAuthorizationWithCompletion:(void (^)(BOOL authorized, NSError * _Nullable error))completion | |
{ | |
__weak typeof(self) weakSelf = self; | |
// request samples within the past week. we want to be relatively sure that we'll get a quick response from this query since it can | |
// block the critical path. if we were to request updates starting now, the user would have to walk around enough to trigger an update before | |
// the completion block would be executed. | |
NSDate *lastWeekDate = [[NSDate date] dateByAddingTimeInterval:-1209600.0]; | |
[self.authorizationPedometer startPedometerUpdatesFromDate:lastWeekDate | |
withHandler:^(CMPedometerData * _Nullable pedometerData, NSError * _Nullable error) { |
This file contains 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
- (void)requestWhenInUseAuthorization | |
{ | |
[CLLocationManager requestWhenInUseAuthorization]; | |
} | |
+ (BOOL)locationServicesAvailable | |
{ | |
BOOL result = [CLLocationManager locationServicesEnabled] && [CLLocationManager authorizationStatus] >= kCLAuthorizationStatusAuthorizedAlways; | |
return result; | |
} |
This file contains 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
__block BOOL areNotificationsAuthorized = NO; | |
[UNUserNotificationCenter getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) { | |
areNotificationsAuthorized = UNAuthorizationStatusAuthorized == settings.authorizationStatus; | |
}]; |
This file contains 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
/// Generate `SCNMaterial` that is the specified color | |
func material(withColor color : UIColor) -> SCNMaterial { | |
let material = SCNMaterial(); | |
material.diffuse.contents = color | |
material.locksAmbientWithDiffuse = true | |
return material | |
} | |
let greenMaterial = material(withColor: UIColor.green) | |
let redMaterial = material(withColor: UIColor.red) |
This file contains 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 BubbleView: UIView { | |
override func draw(_ rect: CGRect) { ... } | |
} |
This file contains 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
extension BubbleView { | |
func drawBubble(in bubbleBounds: CGRect, bubbleColor: UIColor) { | |
// 1. | |
guard let context = UIGraphicsGetCurrentContext() else { return } | |
// 2. | |
context.setFillColor(bubbleColor.cgColor) | |
// 3. | |
context.fillEllipse(in: bounds) | |
} | |
} |
This file contains 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
extension BubbleView { | |
/// Draws a set of stripes across the view up from bottom left | |
/// to top right at a 45 degree angle. The stripes will be | |
/// `stripeWidth` wide and have `stripeWidth` between them. | |
func drawStripes(in bubbleBounds: CGRect, | |
stripeColor: UIColor, | |
stripeWidth: CGFloat) {...} | |
} | |
final class BubbleView: UIView { |
OlderNewer