Reputation: 726
I am trying to set NSString
to NSTextField
of ClassB where the method is called in ClassA. But the NSTextField
is not initializing the value of NSString
.
classB.h
NSString *folderPath;
ClassB.m
- (id)initWithWindow:(NSWindow *)window
{
self = [super initWithWindow:window];
if (self) {
[alertWindow setIsVisible:NO];
[pdfStatusText setStringValue:@"Null"];
}
return self;
}
-(id)initWithAlertWindowControllers:(NSString*)fileName andTitle:(NSString *)title
{
//some part of code here
//i am trying to set String value to the NSTextField pdfStatusText
folderPath=fileName;
[pdfStatusText setStringValue:folderPath];
}
- (void)windowDidLoad
{
[super windowDidLoad];
[self.window makeKeyAndOrderFront:self];
}
classA.m
_alertWindow = [[AlertWindowController alloc] initWithAlertWindowControllers:Path andTitle:@"Project"];
Thank you..
Upvotes: 1
Views: 154
Reputation: 1751
Is you set the value of NSTextField of class B in class A, class A will create a new instance of NSTextField and your textfield will not be initialised. All you have to do is create a IBOutlet of class B in class A. And in the xib drag two NSObject and set their class to class A and class B. Now bind newReferencingOutlet of class B to the IBOutlet object you created in class A by ctlr+drag from classB to classA in xib.
now call the method of class B in class A using this IBOutlet object rather than a new instance of class B.
Upvotes: 0
Reputation: 1663
Your codes should work, try to write NSlog into your method something like it and be sure if your method is working, and then probably your problem is because of your textField -(id)initWithAlertWindowControllers:(NSString*)fileName andTitle:(NSString *)title
{
NSLog(@"Is it working?");
//some part of code here
//i am trying to set String value to the NSTextField pdfStatusText
folderPath=fileName;
pdfStatusText.Text=title;
}
and maybe you should try something like pdfStatusText.delegate=self
; in your view did load method.
Upvotes: 1