mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
Load data into NSData for processing in NSStoryboard
This commit is contained in:
parent
04d131fb44
commit
70a3baa428
3 changed files with 35 additions and 4 deletions
|
@ -41,7 +41,10 @@ typedef NSString *NSStoryboardSceneIdentifier;
|
|||
DEFINE_BLOCK_TYPE(NSStoryboardControllerCreator, NSCoder*, id);
|
||||
|
||||
@interface NSStoryboard : NSObject
|
||||
|
||||
{
|
||||
NSData *_storyboardData;
|
||||
}
|
||||
|
||||
+ (NSStoryboard *) mainStoryboard; // 10.13
|
||||
|
||||
+ (instancetype) storyboardWithName: (NSStoryboardName)name
|
||||
|
|
|
@ -91,7 +91,8 @@ NSApplicationMain(int argc, const char **argv)
|
|||
mainModelFile = [infoDict objectForKey: @"NSMainStoryboardFile"];
|
||||
if (mainModelFile != nil && [mainModelFile isEqual: @""] == NO)
|
||||
{
|
||||
if ([NSBundle loadNibNamed: mainModelFile owner: NSApp] == NO)
|
||||
if ([NSStoryboard storyboardWithName: mainModelFile
|
||||
bundle: [NSBundle mainBundle]] == nil)
|
||||
{
|
||||
NSLog (_(@"Cannot load the main storyboard file '%@'"), mainModelFile);
|
||||
}
|
||||
|
|
|
@ -22,12 +22,31 @@
|
|||
Boston, MA 02110 USA.
|
||||
*/
|
||||
|
||||
#import <AppKit/NSStoryboard.h>
|
||||
#import <Foundation/NSBundle.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSData.h>
|
||||
|
||||
#import "AppKit/NSStoryboard.h"
|
||||
|
||||
static NSStoryboard *mainStoryboard = nil;
|
||||
|
||||
@implementation NSStoryboard
|
||||
|
||||
// Private instance methods...
|
||||
- (id) initWithName: (NSStoryboardName)name
|
||||
bundle: (NSBundle *)bundle
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
NSString *path = [bundle pathForResource: name
|
||||
ofType: @"storyboard"];
|
||||
_storyboardData = [[NSData alloc] initWithContentsOfFile: path];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
// Class methods...
|
||||
+ (NSStoryboard *) mainStoryboard // 10.13
|
||||
{
|
||||
return mainStoryboard;
|
||||
|
@ -36,7 +55,15 @@ static NSStoryboard *mainStoryboard = nil;
|
|||
+ (instancetype) storyboardWithName: (NSStoryboardName)name
|
||||
bundle: (NSBundle *)bundle
|
||||
{
|
||||
return nil;
|
||||
return AUTORELEASE([[NSStoryboard alloc] initWithName: name
|
||||
bundle: bundle]);
|
||||
}
|
||||
|
||||
// Instance methods...
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(_storyboardData);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id) instantiateInitialController
|
||||
|
|
Loading…
Reference in a new issue