views:

60

answers:

2

Hi everybody,

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

+1  A: 

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:.

Peter Hosey
A: 

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?

s0mmer
I'd be surprised if that compiles at all. You mean .m for those implementation file names, right? And where did you put that NSLog statement?
Peter Hosey
Oh, and how you should define the property depends on whether the analyze controller owns the path or not. It probably should. See http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/MemoryMgmt/ for authoritative guidance.
Peter Hosey