2010-03-20 3 views
0

Мое простое приложение для iphone рушится при запуске, он говорит: «приложение downloadText quit неимоверно» Ни одно из этих окон, которое появляется, когда приложение для Mac выходит из строя и отправляется на кнопку Apple. Мой .h ниже, и я был бы очень признателен, если бы кто-нибудь мог дать мне руку о том, что случилось?Приложение Iphone сбой при запуске

#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 

Edit:
консоль поставляется с:

21/03/10 2:32:19 PM downloadText[3548] Stack: 
    (8307803, 2474450491, 8466881, 2787944, 2786485, 25429108, 8210735, 25423659, 
    25431927, 24117515, 24111079, 24110797, 8337, 23594443, 23632310, 23620404, 
    23602815, 23629921, 134489, 8092544, 8088648, 23596565, 23633839, 8252) 
+0

Вам действительно нужно опубликовать причину дампа, чтобы мне не нужно было делать проект в xcode, чтобы помочь вам. – Mobs

ответ

0

Проверьте консоль для отчетов исключений. [Spotlight ищет приложение «Консоль», если вы ленивы. ; -] Любая трассировка стека для предоставления подсказок?

Запуск в симуляторе в режиме отладки. Установите точку останова в начале viewDidLoad, а также в любом месте вашего кода из любой трассировки стека, оставшейся на консоли.

Выполняет ли вызов «[super viewDidLoad]» в первую очередь (вместо последней)? Если это делает какую-либо работу, это может привести к отключению вашего viewDidLoad. Сначала проверьте вывод консоли, хотя я обычно делаю изменения кода только тогда, когда понимаю, что происходит не так, или я могу использовать его, чтобы исключить возможные причины.

+0

спасибо за ответ консоль поставляется с: 21/03/10 2:32:19 PM downloadText [3548] Stack: ( 8307803, 2474450491, 8466881, 2787944, 2786485 , 25429108, 8210735, 25423659, 25431927 , 24117515, 24111079 , 24110797, 8337, 23594443, 23632310 , 23620404, 23602815 , 23629921, 134489, 80 92544, 8088648, 23596565, 23633839,) – declanjs

Смежные вопросы