Skip to content

Commit

Permalink
Fixed crash #237: stop using objectForKeyedSubscript during +load method
Browse files Browse the repository at this point in the history
Added support for separated assemblies in plist for iPhone and iPad
  • Loading branch information
alexgarbarev committed Jul 8, 2014
1 parent e0d9454 commit 5faa974
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
21 changes: 20 additions & 1 deletion Source/Configuration/Startup/TyphoonStartup.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ + (TyphoonComponentFactory *)factoryFromPlist
{
TyphoonComponentFactory *result = nil;

NSArray *assemblyNames = [[NSBundle mainBundle] infoDictionary][@"TyphoonInitialAssemblies"];
NSArray *assemblyNames = [self plistAssemblyNames];
NSAssert(!assemblyNames || [assemblyNames isKindOfClass:[NSArray class]], @"Value for 'TyphoonInitialAssemblies' key must be array");

if ([assemblyNames count] > 0) {
Expand All @@ -60,6 +60,25 @@ + (TyphoonComponentFactory *)factoryFromPlist
return result;
}

+ (NSArray *)plistAssemblyNames
{
NSArray *names = nil;

NSDictionary *bundleInfoDictionary = [[NSBundle mainBundle] infoDictionary];
#if TARGET_OS_IPHONE
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
names = [bundleInfoDictionary objectForKey:@"TyphoonInitialAssemblies(iPad)"];
} else {
names = [bundleInfoDictionary objectForKey:@"TyphoonInitialAssemblies(iPhone)"];
}
#endif
if (!names) {
names = [bundleInfoDictionary objectForKey:@"TyphoonInitialAssemblies"];
}

return names;
}

+ (TyphoonComponentFactory *)factoryFromAppDelegate:(id)appDelegate
{
TyphoonComponentFactory *result = nil;
Expand Down
2 changes: 1 addition & 1 deletion Source/ios/Storyboard/TyphoonInitialStoryboardResolver.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ + (void)swizzleUIStoryboardWithName:(NSString *)storyboardName

+ (NSString *)initialStoryboardName
{
return [[NSBundle mainBundle] infoDictionary][@"UIMainStoryboardFile"];
return [[[NSBundle mainBundle] infoDictionary] objectForKey:@"UIMainStoryboardFile"];
}

@end

0 comments on commit 5faa974

Please sign in to comment.