由于未捕获的异常错误而终止应用程序

时间:2014-01-10 07:34:49

标签: uitextfield

当我点击键盘上的返回时,应用程序应该在文本字段中保存数据。单击返回键时应用程序崩溃。我已将IBActions与#34;在退出时结束"连接到文本字段。在.xib"。这是错误日志:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSPlaceholderString initWithFormat:locale:arguments:]: nil argument'
*** First throw call stack:
(
0   CoreFoundation                      0x0173b5e4 __exceptionPreprocess + 180
1   libobjc.A.dylib                     0x014be8b6 objc_exception_throw + 44
2   CoreFoundation                      0x0173b3bb +[NSException raise:format:] + 139
3   Foundation                          0x010da664 -[NSPlaceholderString initWithFormat:locale:arguments:] + 99
4   Foundation                          0x010da5f4 -[NSString initWithFormat:] + 58
5   Attendance                          0x00002ded -[ShiftAController1 saveRoster1:] + 157
6   libobjc.A.dylib                     0x014d081f -[NSObject performSelector:withObject:] + 70
7   UIKit                               0x0022e0c2 -[UIApplication sendAction:to:from:forEvent:] + 108
8   UIKit                               0x0022e04e -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
9   UIKit                               0x003260c1 -[UIControl sendAction:to:forEvent:] + 66
10  UIKit                               0x00326484 -[UIControl _sendActionsForEvents:withEvent:] + 577
11  UIKit                               0x0032da28 -[UIFieldEditor insertText:] + 263
12  UIKit                               0x0091771f -[UITextField insertText:] + 59
13  UIKit                               0x00409b40 -[UIKeyboardImpl insertText:] + 87
14  UIKit                               0x0041af14 -[TIKeyboardOperationInsertText(UIKeyboardImpl) main] + 83
15  Foundation                          0x01193829 -[__NSOperationInternal _start:] + 671
16  Foundation                          0x01110558 -[NSOperation start] + 83
17  UIKit                               0x004081cd -[UIKeyboardImpl performOperations:] + 153
18  UIKit                               0x0040640b -[UIKeyboardImpl continueHandleKeyboardInputWithOperations:] + 40
19  UIKit                               0x0040627c __73-[UIKeyboardImpl replyHandlerForHandleKeyboardInputWithExecutionContext:]_block_invoke_2 + 44
20  UIKit                               0x0093b3c8 -[UIKeyboardTaskQueue continueExecutionOnMainThread] + 402
21  libobjc.A.dylib                     0x014d081f -[NSObject performSelector:withObject:] + 70
22  Foundation                          0x011139d8 __NSThreadPerformPerform + 285
23  CoreFoundation                      0x016c483f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
24  CoreFoundation                      0x016c41cb __CFRunLoopDoSources0 + 235
25  CoreFoundation                      0x016e129e __CFRunLoopRun + 910
26  CoreFoundation                      0x016e0ac3 CFRunLoopRunSpecific + 467
27  CoreFoundation                      0x016e08db CFRunLoopRunInMode + 123
28  GraphicsServices                    0x036e09e2 GSEventRunModal + 192
29  GraphicsServices                    0x036e0809 GSEventRun + 104
30  UIKit                               0x0022cd3b UIApplicationMain + 1225
31  Attendance                          0x00003a1d main + 141
32  libdyld.dylib                       0x01d7970d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

这是我在.m:

中的代码
-(IBAction)saveRoster1:(id)sender{
myString1 = [[NSString alloc] initWithFormat:roster1.text];
[roster1 setText:myString1];
NSUserDefaults *stringDefault1 = [NSUserDefaults standardUserDefaults];
[stringDefault1 setObject:myString1 forKey:@"stringKey1"];}
-(IBAction)savetimeIn:(id)sender{

myString2 = [[NSString alloc] initWithFormat:timeIn.text];
[timeIn setText:myString2];
NSUserDefaults *stringDefault2 = [NSUserDefaults standardUserDefaults];
[stringDefault2 setObject:myString2 forKey:@"stringKey2"];}
-(IBAction)savetimeOut:(id)sender{

myString3 = [[NSString alloc] initWithFormat:timeOut.text];
[timeOut setText:myString3];
NSUserDefaults *stringDefault3 = [NSUserDefaults standardUserDefaults];
[stringDefault3 setObject:myString3 forKey:@"stringKey3"];}

0 个答案:

没有答案