Hey,
My simple iphone app is crashing on launch, it says "the application downloadText quit unexcpectedly i none of these windows that pop up when a mac app crashes and has a send to Apple button. My .h is below and i would greatly appreciate it if anyone could give me a hand as to what's wrong?
thanks,
Declan
`#import "downloadTextViewController.h"
@implementation downloadTextViewController
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
NSString *myPath = [self saveFilePath];
NSLog(myPath);
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:myPath];
if (fileExists)
{
NSArray *values = [[NSArray alloc] initWithContentsOfFile:myPath];
textView.text = [values objectAtIndex:0];
[values release];
}
// notification
UIApplication *myApp = [UIApplication sharedApplication];
// add yourself to the dispatch table
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationWillTerminate:)
name:UIApplicationWillTerminateNotification
object:myApp];
[super viewDidLoad];
}
(IBAction)fetchData {
/// Show activityIndicator / progressView
NSURLRequest *downloadRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://simpsonatyapps.com/exampletext.txt"]
cachePolicy:NSURLRequestReloadIgnoringCacheData
timeoutInterval:1.0];
NSURLConnection *downloadConnection = [[NSURLConnection alloc] initWithRequest:downloadRequest delegate:self];
if (downloadConnection)
downloadedData = [[NSMutableData data] retain];
else {
/// Error message
}
}
(void)connection:(NSURLConnection *)downloadConnection didReceiveData:(NSData *)data {
[downloadedData appendData:data];
NSString *file = [[NSString alloc] initWithData:downloadedData encoding:NSUTF8StringEncoding];
textView.text = file;
/// Remove activityIndicator / progressView
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:1];
}
(NSString *) saveFilePath
{
NSArray *pathArray =
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
return [[pathArray objectAtIndex:0] stringByAppendingPathComponent:@"savedddata.plist"];
}
(void)applicationWillTerminate:(UIApplication *)application {
NSArray *values = [[NSArray alloc] initWithObjects:textView.text,nil];
[values writeToFile:[self saveFilePath] atomically:YES];
[values release];
}
(void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
(void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
(void)dealloc {
[super dealloc];
}
(NSCachedURLResponse *)connection:(NSURLConnection *)connection willCacheResponse:(NSCachedURLResponse *)cachedResponse {
return nil;
}
@end
`