开发者

How to share information across controllers?

I recently started programming my first Cocoa app. I have ran into a problem i hope you can help me with.

I have a MainController who controls the user browsing his computer and sets some textfield = the chosen folder.

I need to retrieve that chosen folder in my AnalyzeController in order to do some work. How do i pass the textfield objectValue from the MainController to the AnalyzeController?

Thanks


Alright this it what i came up with:

MainController.h:
#import "AnalyzeController.h"
@interface MainController : NSObject {
    AnalyzeController* analyzeControl;
}

MainController.c:
analyzeControl = [[AnalyzeController alloc]init]; 
[analyzeControl setDevelopmentPath:filename];

AnalyzeController.h:
@interface AnalyzeController : NSObject {
NSString* developmentPath;
}
@property(assign) 开发者_运维百科NSString* developmentPath;

AnalyzeController.c:
@synthesize developmentPath;
NSLog(@"FINAL TEST: %@", developmentPath);

But i end up with the test returning NULL. I was a bit unsure about what the property parameter should be. Can you help? Or did i get it all wrong?


How do i pass the textfield objectValue from the MainController to the AnalyzeController?

Do that.

[analyzeController setFolderPath:self.mainFolderPath];

I assume that either you bound the text field to the mainFolderPath property, or you assigned to the property when the field's value changed.

I also assume that, in writing the AnalyzeController, you gave it a property named folderPath or at least a setter named setFolderPath:.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜