我需要在另一个类中访问这个 IBOutlet 的值。我该怎么做呢?
这是我的 SaveTextViewController.h 类
#import <UIKit/UIKit.h>
@interface SaveTextViewController : UIViewController{
IBOutlet UITextField *saveText;
}
@property (retain, nonatomic) IBOutlet UITextField *saveText;
@end
这是我的 TextView.m 类
#import "TextView.h"
#import "SaveTextViewController.h"
@implementation TextView
- (IBAction)saveTextView{
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [documentPaths objectAtIndex:0];
//Trying to access the returned variable "saveText" from IBOutlet in SaveTextViewController
NSString *documentTXTPath = [documentsDirectory stringByAppendingPathComponent:@"%d",saveText];
NSString *savedString = self.text;
[savedString writeToFile:documentTXTPath atomically:YES];
NSLog(@"%@", documentTXTPath);
}
谢谢!