mirror of
https://github.com/darlinghq/darling-cocotron.git
synced 2024-11-23 12:09:51 +00:00
Add Private Properties, Implement storyboardWithName:bundle:
This commit is contained in:
parent
74a946476e
commit
a849c713d0
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user