From a849c713d09838da8c5c1a97f340f0d7f8112299 Mon Sep 17 00:00:00 2001 From: Thomas A Date: Wed, 19 Aug 2020 08:24:51 -0700 Subject: [PATCH] Add Private Properties, Implement storyboardWithName:bundle: --- AppKit/NSStoryboard.m | 36 +++++++++++++++++++++++++++- AppKit/include/AppKit/NSStoryboard.h | 8 ++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/AppKit/NSStoryboard.m b/AppKit/NSStoryboard.m index f38ad6e9..091222a4 100644 --- a/AppKit/NSStoryboard.m +++ b/AppKit/NSStoryboard.m @@ -1,10 +1,40 @@ #import -@implementation NSStoryboard +@interface NSStoryboard () + +@property NSString *storyboardPath; +@property NSString *initialController; +@property NSDictionary *dictIdentifier; +@property NSDictionary *dictUUID; +@property NSNumber *versionNumber; + +@end + + +@implementation NSStoryboard + +@dynamic mainStoryboard; +@synthesize storyboardPath = _storyboardPath; +@synthesize initialController = _initialController; +@synthesize dictIdentifier = _dictIdentifier; +@synthesize dictUUID = _dictUUID; +@synthesize versionNumber = _versionNumber; + (instancetype)storyboardWithName:(NSStoryboardName)name bundle:(NSBundle*)storyboardBundleOrNil { NSStoryboard *sb = [[NSStoryboard alloc] init]; + NSBundle *storyboardBundle = storyboardBundleOrNil == nil ? [NSBundle mainBundle] : storyboardBundleOrNil; + NSString *storyboardPath = [storyboardBundle pathForResource:name ofType:@"storyboardc"]; + + NSString *const infoPath = [storyboardPath stringByAppendingString:@"/Info.plist"]; + NSData *storyboardData = [NSData dataWithContentsOfFile:infoPath]; + NSDictionary *infoDict = [NSPropertyListSerialization propertyListWithData:storyboardData options:NSPropertyListImmutable format:nil error:nil]; + + [sb setStoryboardPath:storyboardPath]; + [sb setDictIdentifier:infoDict[@"NSViewControllerIdentifiersToNibNames"]]; + [sb setDictUUID:infoDict[@"NSViewControllerIdentifiersToUUIDs"]]; + [sb setInitialController:infoDict[@"NSStoryboardMainMenu"]]; + [sb setVersionNumber:infoDict[@"NSStoryboardVersion"]]; return [sb autorelease]; } @@ -24,4 +54,8 @@ return nil; } +- (NSStoryboard *)mainStoryboard { + return nil; +} + @end diff --git a/AppKit/include/AppKit/NSStoryboard.h b/AppKit/include/AppKit/NSStoryboard.h index 32cfa92d..fd02e3a7 100644 --- a/AppKit/include/AppKit/NSStoryboard.h +++ b/AppKit/include/AppKit/NSStoryboard.h @@ -6,7 +6,13 @@ typedef NSString *NSStoryboardSceneIdentifier; typedef id _Nullable (^NSStoryboardControllerCreator)(NSCoder * _Nonnull coder); -@interface NSStoryboard : NSObject +@interface NSStoryboard : NSObject { + NSString *_storyboardPath; + NSString *_initialController; + NSDictionary *_dictIdentifier; + NSDictionary *_dictUUID; + NSNumber *_versionNumber; +} @property(class, readonly, strong) NSStoryboard * _Nullable mainStoryboard;