使用sqlite在uitableview中动态存储数据

时间:2016-02-12 13:27:13

标签: ios sqlite

代码:

NSString *Query=[NSString stringWithFormat:@"select *from peopleinfm where peopleinfmID=%d",TextEdit];
NSArray *Results=[[NSArray alloc]initWithArray:[DBManger loadDataFromDB:Query]];
self.FirstnameText.text=[[Results objectAtIndex:1]objectAtIndex:[self.DBManger.ColumnArray indexOfObject:@"firstname"]];
self.LastnameText.text=[[Results objectAtIndex:1]objectAtIndex:[self.DBManger.ColumnArray indexOfObject:@"lastname"]];
self.AgeText.text=[[Results objectAtIndex:1]objectAtIndex:[self.DBManger.ColumnArray indexOfObject:@"age"]];

日志:

2016-02-12 19:03:36.068 SampleFMDB[9641:762577] no such table: peopleinfm
2016-02-12 19:03:36.077 SampleFMDB[9641:762577] _UIConstraintBasedLayoutLogUnsatisfiable is OFF
2016-02-12 19:03:37.934 SampleFMDB[9641:762577] no such table: peopleinfm
2016-02-12 19:03:37.978 SampleFMDB[9641:762577] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArray0 objectAtIndex:]: index 1 beyond bounds for empty NSArray'
*** First throw call stack:
(
0   CoreFoundation                      0x00b23a94 __exceptionPreprocess + 180
1   libobjc.A.dylib                     0x005e2e02 objc_exception_throw + 50
2   CoreFoundation                      0x00aca4a0 __CFArrayGetTypeID_block_invoke + 0
3   SampleFMDB                          0x00010003 -[AddViewController loadInfoToEdit] + 291
4   SampleFMDB                          0x0000f9bc -[AddViewController viewDidLoad] + 396
5   UIKit                               0x01070d74 -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 44
6   UIKit                               0x010758c2 -[UIViewController loadViewIfRequired] + 1556
7   UIKit                               0x0107bf0e -[UIViewController __viewWillAppear:] + 114
8   UIKit                               0x0109ecf0 -[UIViewController(UIContainerViewControllerProtectedMethods) beginAppearanceTransition:animated:] + 202
9   UIKit                               0x010b0d63 -[UINavigationController _startCustomTransition:] + 1375
10  UIKit                               0x010c1c0b -[UINavigationController _startDeferredTransitionIfNeeded:] + 801
11  UIKit                               0x010c2d05 -[UINavigationController __viewWillLayoutSubviews] + 68
12  UIKit                               0x0128cd9f -[UILayoutContainerView layoutSubviews] + 252
13  UIKit                               0x00f7916b -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 813
14  libobjc.A.dylib                     0x005f7059 -[NSObject performSelector:withObject:] + 70
15  QuartzCore                          0x048ae60c -[CALayer layoutSublayers] + 144
16  QuartzCore                          0x048a228e _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 388
17  QuartzCore                          0x048a20f2 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
18  QuartzCore                          0x04894c2b _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 317
19  QuartzCore                          0x048c8c23 _ZN2CA11Transaction6commitEv + 589
20  QuartzCore                          0x048ca484 _ZN2CA11Transaction17flush_transactionEv + 50
21  UIKit                               0x00eadb55 _UIApplicationHandleEventQueue + 7921
22  CoreFoundation                      0x00a3de7f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
23  CoreFoundation                      0x00a33b0b __CFRunLoopDoSources0 + 523
24  CoreFoundation                      0x00a32f28 __CFRunLoopRun + 1032
25  CoreFoundation                      0x00a32866 CFRunLoopRunSpecific + 470
26  CoreFoundation                      0x00a3267b CFRunLoopRunInMode + 123
27  GraphicsServices                    0x04148664 GSEventRunModal + 192
28  GraphicsServices                    0x041484a1 GSEventRun + 104
29  UIKit                               0x00eb3cc1 UIApplicationMain + 160
30  SampleFMDB                          0x000108ea main + 138
31  libdyld.dylib                       0x030f6a21 start + 1
)
 libc++abi.dylib: terminating with uncaught exception of type NSException

0 个答案:

没有答案