Add Private Properties, Implement storyboardWithName:bundle:

This commit is contained in:
Thomas A 2020-08-19 08:24:51 -07:00
parent 74a946476e
commit a849c713d0
2 changed files with 42 additions and 2 deletions

View File

@ -1,10 +1,40 @@
#import <AppKit/NSStoryboard.h>
@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

View File

@ -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;