I made a simple app as below, when I compiled it, I got a "Build Failed" error, I don"t why, pls help me.
Code:
// PersistenceViewController.h
#import <UIKit/UIKit.h>
#define kFilename @"trade.plist"
@interface PersistenceViewController : UIViewController {
UITextField *startDate;
UITextField *endDate;
UITextField *tradeType;
UITextField *account;
UITextField *code;
UITextField *amount;
UITextField *startPrice;
UITextField *endPrice;
UITextField *value;
UITextField *profitLoss;
UITextField *profitLossRate;
UITextField *fee;
UITextField *tax;
UITextField *interest;
}
@property (nonatomic, retain) IBOutlet UITextField *startDate;
@property (nonatomic, retain) IBOutlet UITextField *endDate;
@property (nonatomic, retain) IBOutlet UITextField *tradeType;
@property (nonatomic, retain) IBOutlet UITextField *account;
@property (nonatomic, retain) IBOutlet UITextField *code;
@property (nonatomic, retain) IBOutlet UITextField *amount;
@property (nonatomic, retain) IBOutlet UITextField *startPrice;
@property (nonatomic, retain) IBOutlet UITextField *endPrice;
@property (nonatomic, retain) IBOutlet UITextField *value;
@property (nonatomic, retain) IBOutlet UITextField *profitLoss;
@property (nonatomic, retain) IBOutlet UITextField *profitLossRate;
@property (nonatomic, retain) IBOutlet UITextField *fee;
@property (nonatomic, retain) IBOutlet UITextField *tax;
@property (nonatomic, retain) IBOutlet UITextField *interest;
-(NSString *) dataFilePath;
-(void) applicationWillTerminate:(NSNotification *)notification;
@end
Code:
// PersistenceViewController.m
#import "PersistenceViewController.h"
@implementation PersistenceViewController
@synthesize startDate;
@synthesize endDate;
@synthesize tradeType;
@synthesize account;
@synthesize code;
@synthesize amount;
@synthesize startPrice;
@synthesize endPrice;
@synthesize value;
@synthesize profitLoss;
@synthesize profitLossRate;
@synthesize fee;
@synthesize tax;
@synthesize interest;
-(NSString *) dataFilePath {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
return [documentsDirectory stringByAppendingPathComponent:kFilename];
}
-(void) applicationWillTerminate:(NSNotification *)notification {
NSMutableArray *array = [[NSMutableArray alloc] init];
[array addObject:startDate.text];
[array addObject:endDate.text];
[array addObject:tradeType.text];
[array addObject:account.text];
[array addObject:code.text];
[array addObject:amount.text];
[array addObject:startPrice.text];
[array addObject:endPrice.text];
[array addObject:value.text];
[array addObject:profitLoss.text];
[array addObject:profitLossRate.text];
[array addObject:fee.text];
[array addObject:tax.text];
[array addObject:interest.text];
[array writeToFile:[self dataFilePath] atomically:YES];
[array release];
}
- (void)viewDidLoad {
NSString *filePath = [self dataFilePath];
if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) {
NSArray *array = [[NSArray alloc] initWithContentsOfFile:filePath];
startDate.text = [array objectAtIndex:0];
endDate.text = [array objectAtIndex:1];
tradeType.text = [array objectAtIndex:2];
account.text = [array objectAtIndex:3];
code.text = [array objectAtIndex:4];
amount.text = [array objectAtIndex:5];
startPrice.text = [array objectAtIndex:6];
endPrice.text = [array objectAtIndex:7];
value.text = [array objectAtIndex:8];
profitLoss.text = [array objectAtIndex:9];
profitLossRate.text = [array objectAtIndex:10];
fee.text = [array objectAtIndex:11];
tax.text = [array objectAtIndex:12];
interest.text = [array objectAtIndex:12];
[array release];
}
UIApplication *app = [UIApplication sharedApplication];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:UIApplicationWillTerminateNotification object:app];
[super viewDidLoad];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (void)viewDidUnload {
self.startDate = nil;
self.endDate = nil;
self.account = nil;
self.code = nil;
self.amount = nil;
self.startPrice = nil;
self.endPrice = nil;
self.value = nil;
self.profitLoss = nil;
self.profitLossRate = nil;
self.fee = nil;
self.tax = nil;
self.interest = nil;
[super viewDidUnload];
}
- (void)dealloc {
[startDate release];
[endDate release];
[account release];
[code release];
[amount release];
[startPrice release];
[endPrice release];
[value release];
[profitLoss release];
[profitLossRate release];
[fee release];
[tax release];
[interest release];
[super dealloc];
}
@end
Code:
ProcessPCH /var/folders/+D/+DggSL7nF8OME3lFbWxEDk+++TI/-Caches-/com.apple.Xcode.501/SharedPrecompiledHeaders/Persistence_Prefix-edniqrejmxqmlcfvjocrpdtfmsme/Persistence_Prefix.pch.gch Persistence_Prefix.pch normal i386 objective-c com.apple.compilers.gcc.4_2
cd /Users/mikezang/iPad/MyApp/Persistence
setenv LANG en_US.US-ASCII
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -x objective-c-header -arch i386 -fmessage-length=0 -pipe -std=c99 -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused-variable -D__IPHONE_OS_VERSION_MIN_REQUIRED=30200 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.2.sdk -fvisibility=hidden -mmacosx-version-min=10.5 -gdwarf-2 -fobjc-abi-version=2 -fobjc-legacy-dispatch -iquote /Users/mikezang/iPad/MyApp/Persistence/build/Persistence.build/Debug-iphonesimulator/Persistence.build/Persistence-generated-files.hmap -I/Users/mikezang/iPad/MyApp/Persistence/build/Persistence.build/Debug-iphonesimulator/Persistence.build/Persistence-own-target-headers.hmap -I/Users/mikezang/iPad/MyApp/Persistence/build/Persistence.build/Debug-iphonesimulator/Persistence.build/Persistence-all-target-headers.hmap -iquote /Users/mikezang/iPad/MyApp/Persistence/build/Persistence.build/Debug-iphonesimulator/Persistence.build/Persistence-project-headers.hmap -F/Users/mikezang/iPad/MyApp/Persistence/build/Debug-iphonesimulator -I/Users/mikezang/iPad/MyApp/Persistence/build/Debug-iphonesimulator/include -I/Users/mikezang/iPad/MyApp/Persistence/build/Persistence.build/Debug-iphonesimulator/Persistence.build/DerivedSources/i386 -I/Users/mikezang/iPad/MyApp/Persistence/build/Persistence.build/Debug-iphonesimulator/Persistence.build/DerivedSources ? filePath -c /Users/mikezang/iPad/MyApp/Persistence/Persistence_Prefix.pch -o /var/folders/+D/+DggSL7nF8OME3lFbWxEDk+++TI/-Caches-/com.apple.Xcode.501/SharedPrecompiledHeaders/Persistence_Prefix-edniqrejmxqmlcfvjocrpdtfmsme/Persistence_Prefix.pch.gch
i686-apple-darwin10-gcc-4.2.1: ?: No such file or directory
i686-apple-darwin10-gcc-4.2.1: filePath: No such file or directory
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1