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
// Create a progress bar view | |
UIProgressView *progressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleBar]; | |
progressView.progress = 0; | |
// Assume we have a progress object | |
NSProgress *progress = [self progressForOngoingTask]; | |
// Observe the 'fractionCompleted' property and update the progress view as it changes | |
[self.KVOController observe:progress keyPath:@"fractionCompleted" options:NSKeyValueObservingOptionNew block:^(id _Nullable observer, id _Nonnull object, NSDictionary<NSString *, id> *_Nonnull change) { | |
dispatch_async(dispatch_get_main_queue(), ^{ |
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
NSURL *pathToPdfFile; | |
UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:@[ result ] applicationActivities:nil]; | |
NSMutableArray *excludedActivities = [NSMutableArray array]; | |
NSNumber *emailOutEnabled = [self.userPreferences.featureFlags valueForKeyPath:@"research.share.email"]; | |
if (!emailOutEnabled.boolValue) { | |
[excludedActivities addObject:UIActivityTypeMail]; | |
} |
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
- (void)interceptSeguesToPerformDependencyInjection { | |
NSError *error; | |
id<AspectToken> DIAspectToken = [UIViewController aspect_hookSelector:@selector(prepareForSegue:sender:) withOptions:AspectPositionBefore usingBlock:^(id<AspectInfo> aspectInfo, UIStoryboardSegue *segue, id sender) { | |
UIViewController *destinationController = segue.destinationViewController; | |
[self.UIAssembly inject:destinationController]; | |
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
- (void)showNoteSplitViewWithDataController:(DataController *)dataController searchController:(SearchController *)searchController { | |
NSParameterAssert(dataController); | |
NSParameterAssert(searchController); | |
NSString *authenticatedUserId = self.applicationSessionCredentialStore.userId; | |
NoteSplitViewAssembly *assembly = [self.assembly noteSplitViewAssemblyWithApplicationSession:self.applicationSession dataController:dataController searchController:searchController authenticatedUserId:authenticatedUserId]; | |
[assembly activate]; |
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
@interface CoordinatorAssembly | |
@property (strong, nonatomic) DependencyOne *existingInjectedDependency; | |
- (DependencyTwo *)newDependency; | |
- (MyModel *)modelThatIsInjectedWithBothDependencies; | |
@end |
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
@implementation ExampleAssembly | |
- (MyModel *)model { | |
return [TyphoonDefinition withClass:[MyModel class] | |
configuration:^(TyphoonDefinition* definition) { | |
[definition useInitializer:@selector(initWithDependency:) | |
parameters:^(TyphoonMethod *initializer) { | |
[initializer injectParameterWith:[self exampleDependency]]; |
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
JSObjectionInjector *injector = [JSObjection createInjector]; | |
[injector bindBlock:^(JSObjectionInjector *context) { | |
MyModel *model = [[MyModel alloc] initWithDependency:context.getObject([Dependency class])]; | |
return model; | |
} toClass:[MyModel class]]; | |
id myModel = [injector getObject:[MyModel class]]; |
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
@implementation MyViewController | |
+ (BSInitializer *)bsInitializer { | |
return [BSInitializer initializerWithClass:self | |
selector:@selector(initWithApi:) | |
argumentKeys:@"myApi", nil]; | |
} | |
- (instancetype)initWithApi:(MyApi *)myApi { | |
... |
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 "AppDelegate.h" | |
#import "AppCoordinator.h" | |
@interface AppDelegate () | |
@property (strong, nonatomic) AppCoordinator *coordinator; | |
@end | |
@implementation AppDelegate |
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 "AppDelegate.h" | |
@interface AppDelegate () | |
@property (strong, nonatomic) NSManagedObjectContext *managedObjectContext; | |
@property (strong, nonatomic) GCDWebServer *webServer; | |
@end | |
@implementation AppDelegate |