TTMessageController崩溃

时间:2011-01-11 04:26:20

标签: cocoa-touch three20

我有一个使用Three20框架的项目,我正在使用网址映射,toModalViewController从Launcher打开自定义TTMessageController。我已经让那部分工作得很好,但我一直在经历一些奇怪的崩溃。

如果我键入一点,切换到另一个字段,键入更多,并重复几次应用程序将崩溃并出现错误:

  

因未捕获而终止应用   异常'NSRangeException',原因:   ' * - [NSMutableArray objectAtIndex:]:   索引2超出界限[0 .. 1]'

我花了几个小时梳理代码,但是我没有看到任何导致崩溃的事情。我可能会错过一些非常明显的东西,但是......

如果您不介意的话,这是课程:

#import "ComposeLinkViewController.h"


@implementation ComposeLinkViewController


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self = [self doComposeLinkUI];
    }
    return self;
}



- (UIViewController *)doComposeLinkUI {
    TTMessageController *controller = [[TTMessageController alloc] init];
    controller.delegate = self;
    controller.title = @"New Link";

    TTMessageTextField *titleField = [[[TTMessageTextField alloc]
                                           initWithTitle:@"Link Text" required:YES] autorelease];
    TTMessageTextField *linkURL = [[[TTMessageTextField alloc]
                                initWithTitle:@"URL" required:YES] autorelease];
    TTMessageField *comment = [[[TTMessageField alloc]
                                initWithTitle:@"Comment" required:NO] autorelease];
    controller.fields = [NSArray arrayWithObjects:titleField, comment, linkURL, nil];

    return [controller autorelease];
}



/*- (void)loadView {
}*/



/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/



- (void)composeController:(TTMessageController*)controller didSendFields:(NSArray*)fields {
    //Send the data
}



- (void)composeControllerDidCancel:(TTMessageController*)controller {
    [self dismissModalViewControllerAnimated:YES];
}



- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return TTIsSupportedOrientation(interfaceOrientation);
}

- (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 {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}


@end

好像这不够奇怪,单击“取消”按钮时出现同样的错误。我实现了委托方法(以及头文件中的协议)。

编辑:这是堆栈跟踪......

2011-01-11 00:57:49.783 PocketPress[60432:207] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index 2 beyond bounds [0 .. 1]'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x010a5be9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x011fa5c2 objc_exception_throw + 47
    2   CoreFoundation                      0x0109b6e5 -[__NSArrayM objectAtIndex:] + 261
    3   PocketPress                         0x0004e239 -[TTMessageController hasRequiredText] + 490
    4   PocketPress                         0x0004e2dd -[TTMessageController updateSendCommand] + 37
    5   PocketPress                         0x0004fa4e -[TTMessageController textEditorDidChange:] + 36
    6   PocketPress                         0x00093684 -[TTTextEditorInternal textViewDidChange:] + 187
    7   Foundation                          0x001d07f6 __NSFireDelayedPerform + 441
    8   CoreFoundation                      0x01086fe3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19
    9   CoreFoundation                      0x01088594 __CFRunLoopDoTimer + 1220
    10  CoreFoundation                      0x00fe4cc9 __CFRunLoopRun + 1817
    11  CoreFoundation                      0x00fe4240 CFRunLoopRunSpecific + 208
    12  CoreFoundation                      0x00fe4161 CFRunLoopRunInMode + 97
    13  GraphicsServices                    0x019da268 GSEventRunModal + 217
    14  GraphicsServices                    0x019da32d GSEventRun + 115
    15  UIKit                               0x0046042e UIApplicationMain + 1160
    16  PocketPress                         0x00001f76 main + 104
    17  PocketPress                         0x00001f05 start + 53
    18  ???                                 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'

Ť

0 个答案:

没有答案