【发布时间】:2015-04-23 15:51:03
【问题描述】:
在这里需要真正的帮助!!!
我正在尝试在二等舱中使用在一等舱中创建的数据。我已经搜索 Youtube 和 StackOverflow 超过 1 周了。每次我觉得我很接近时,都会缺少一些我无法把握的元素。我最近的尝试来自于 2011 年发布的这个站点(在目标 c 类之间传递数据),当应用程序编译时,我看不到第二类中的数据。
更具体。我正在使用 2 个类,因为数据是按用户选择的组(第 1 类)收集的,并将在屏幕上显示在第 2 类的表格中。有 6 个 NSMutable 数组从源传递到第二类中的 6 个不同。我会继续尝试解决,但我可以使用帮助。
这是我从 2011 年的文章中得出的结论:
1st class .h 代码(部分):
#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>
#import "ReportsOutput.h"
//@class AppDelegate;
@class ReportsOutput;
@interface ReportsClass : NSWindowController<NSApplicationDelegate,NSMenuDelegate,NSWindowDelegate>{
ReportsOutput *ro;
//Shared Data arrays
NSMutableArray *tblYrScott;
NSMutableArray *tblYrExt;
NSMutableArray *tblYrYear;
NSMutableArray *tblYrType;
NSMutableArray *tblYrPrice;
NSMutableArray *tblYrDescription;
...... added code
@property(nonatomic,retain)NSMutableArray *tblYrScott;
@property(nonatomic,retain)NSMutableArray *tblYrExt;
@property(nonatomic,retain)NSMutableArray *tblYrType;
@property(nonatomic,retain)NSMutableArray *tblYrYear;
@property(nonatomic,retain)NSMutableArray *tblYrPrice;
@property(nonatomic,retain)NSMutableArray *tblYrDescription;
一级 .m 代码:
- (IBAction)btnShowDataOutput:(id)sender {
//pass data from Reports Class to Report Output Class
ReportsOutput *objReportsOutput = [[ReportsOutput alloc]init];
[objReportsOutput.tblScott setArray: tblYrScott];
[objReportsOutput.tblExt setArray:tblYrDescription];
[objReportsOutput.tblYear setArray:tblYrYear];
[objReportsOutput.tblType setArray:tblYrType];
[objReportsOutput.tblDescription setArray:tblYrDescription];
// open Reports Output Window
if (ro == nil){
ro = [[ReportsOutput alloc] initWithWindowNibName:@"ReportsOutput"];
}
[ro showWindow:nil];
}
二级 .h 代码:
#import <Cocoa/Cocoa.h>
#import "ReportsClass.h"
@interface ReportsOutput : NSWindowController{
//shared data arrays
NSMutableArray *tblScott;
NSMutableArray *tblExt;
NSMutableArray *tblYear;
NSMutableArray *tblType;
NSMutableArray *tblPrice;
NSMutableArray *tblDescription;
}
@property(nonatomic,strong) NSMutableArray *tblScott;
@property(nonatomic,strong) NSMutableArray *tblExt;
@property(nonatomic,strong) NSMutableArray *tblYear;
@property(nonatomic,strong) NSMutableArray *tblType;
@property(nonatomic,strong) NSMutableArray *tblPrice;
@property(nonatomic,strong) NSMutableArray *tblDescription;
@end
二级 .m 代码:
#import "ReportsOutput.h"
//#import "ReportsClass.h"
@interface ReportsOutput ()
@end
@implementation ReportsOutput
@synthesize tblScott;
@synthesize tblExt;
@synthesize tblType;
@synthesize tblPrice;
@synthesize tblYear;
@synthesize tblDescription;
- (void)windowDidLoad {
[super windowDidLoad];
}
-(void)awakeFromNib{
[self dataCheck];
}
-(void)dataCheck{
int a;
for (a=0; a<[self.tblScott count]; a++){
NSLog(@"@i,%d :%@: %@: %@: %@: %@: %@",a,[tblScott objectAtIndex:a],[tblExt objectAtIndex:a],[tblYear objectAtIndex:a],[tblType objectAtIndex:a],[tblPrice objectAtIndex:a],[tblDescription objectAtIndex:a]);
}
}
【问题讨论】:
-
所以基本上你想从第一个视图控制器转到第二个视图控制器并在 segue 期间传递一些数据?
标签: objective-c macos cocoa osx-yosemite