I cannot get this simple string to write to a file.
Please look at my code. This is a simple nib with an NSTextField
and a button. The log shows I am getting the string value fine, but it does not write.
//Quick.h
#import <Foundation/Foundation.h>
@interface Quick : NSObject
{
IBOutlet NSTextField * aString;
}
-(IBAction)wButton:(id)sender;
@end
//Quick.m
#import "Quick.h"
@implementation Quick
- (id)init
{
self = [super init];
if (self) {
// Initialization code here.
}
return self;
}
-(IBAction)wButton:(id)sender{
NSString * zStr = [aString stringValue];
NSString * path = @"data.txt";
NSLog(@"test String %@", zStr);
[zStr writeToFile:path
atomically:YES
encoding:NSASCIIStringEncoding
error:nil];
}
@end