Change the text of UINavigationController not working in Swift - ios

I have an app which has 5 UIViewControllers and the rootViewController is attached to a UINavigationController and the others are connected by segues. Now, I want to add a title to the UINavigationController. I have tried different things in viewDidLoad and viewDidAppear:
self.text = "Hello" // Runtime Error
self.navigationController?.navigationBar.topItem?.title = "Hello" // Runtime Error
self.navigationController?.visibleViewController.title = "Hello" // Runtime Error
The UIViewController that I am calling this is like this:
class LoginTypeActivityViewController: PPViewController{
}
Where, PPViewController is declared like this:
class PPViewController: UIViewController{
}
The runtime error is:
2014-10-13 17:21:27.878 mobilepay[29387:1382271] -[Swift._NSContiguousString set]: unrecognized selector sent to instance 0x7b6b33d0
2014-10-13 17:21:27.881 mobilepay[29387:1382271] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Swift._NSContiguousString set]: unrecognized selector sent to instance 0x7b6b33d0'
*** First throw call stack:
(
0 CoreFoundation 0x00bb5df6 __exceptionPreprocess + 182
1 libobjc.A.dylib 0x0083fa97 objc_exception_throw + 44
2 CoreFoundation 0x00bbda75 -[NSObject(NSObject) doesNotRecognizeSelector:] + 277
3 CoreFoundation 0x00b069c7 ___forwarding___ + 1047
4 CoreFoundation 0x00b0658e _CF_forwarding_prep_0 + 14
5 UIFoundation 0x067eeb91 __NSStringDrawingEngine + 29221
6 UIFoundation 0x067e784d -[NSString(NSExtendedStringDrawing) drawWithRect:options:attributes:context:] + 171
7 UIKit 0x013be151 -[UILabel _drawTextInRect:baselineCalculationOnly:] + 6626
8 UIKit 0x013bbe30 -[UILabel drawTextInRect:] + 581
9 UIKit 0x013be256 -[UILabel drawRect:] + 98
10 UIKit 0x0123354b -[UIView(CALayerDelegate) drawLayer:inContext:] + 519
11 QuartzCore 0x01077d51 -[CALayer drawInContext:] + 118
12 QuartzCore 0x01077c87 _ZL16backing_callbackP9CGContextPv + 96
13 QuartzCore 0x00f5c7ae CABackingStoreUpdate_ + 2788
14 QuartzCore 0x01077c1f ___ZN2CA5Layer8display_Ev_block_invoke + 93
15 QuartzCore 0x010ad406 x_blame_allocations + 15
16 QuartzCore 0x01077a85 _ZN2CA5Layer8display_Ev + 1591
17 QuartzCore 0x01077cd6 -[CALayer _display] + 33
18 QuartzCore 0x01077446 _ZN2CA5Layer7displayEv + 142
19 QuartzCore 0x01077cb0 -[CALayer display] + 33
20 QuartzCore 0x0106bee6 _ZN2CA5Layer17display_if_neededEPNS_11TransactionE + 322
21 QuartzCore 0x0106bf6c _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 38
22 QuartzCore 0x00fca676 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 284
23 QuartzCore 0x00fcba3c _ZN2CA11Transaction6commitEv + 392
24 QuartzCore 0x00fcc108 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
25 CoreFoundation 0x00ad8fbe __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
26 CoreFoundation 0x00ad8f00 __CFRunLoopDoObservers + 400
27 CoreFoundation 0x00ace93a __CFRunLoopRun + 1226
28 CoreFoundation 0x00ace1ab CFRunLoopRunSpecific + 443
29 CoreFoundation 0x00acdfdb CFRunLoopRunInMode + 123
30 GraphicsServices 0x0317124f GSEventRunModal + 192
31 GraphicsServices 0x0317108c GSEventRun + 104
32 UIKit 0x011a8e16 UIApplicationMain + 1526
33 mobilepay 0x001410de top_level_code + 78
34 mobilepay 0x0014111b main + 43
35 libdyld.dylib 0x03ad7ac9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
What can be the error? I am stuck since the last 5 hours here.
I am trying to set the title different in different UIViewControllers.

In your viewDidLoad(), type:
title = "Hello World"

Related

Not able to find crash Swift

App is crashing with these logs, but couldn't able to find what's causing the crash
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull set]: unrecognized selector sent to instance 0x118f33590'
*** First throw call stack:
(
0 CoreFoundation 0x0000000118ccf8ab __exceptionPreprocess + 242
1 libobjc.A.dylib 0x00000001117a5ba3 objc_exception_throw + 48
2 CoreFoundation 0x0000000118cdeab8 +[NSObject(NSObject) instanceMethodSignatureForSelector:] + 0
3 CoreFoundation 0x0000000118cd3d71 ___forwarding___ + 1431
4 CoreFoundation 0x0000000118cd6068 _CF_forwarding_prep_0 + 120
5 UIFoundation 0x0000000125ff888b -[NSCoreTypesetter _NSFastDrawString:length:attributes:paragraphStyle:typesetterBehavior:lineBreakMode:rect:padding:graphicsContext:baselineRendering:usesFontLeading:usesScreenFont:scrollable:syncAlignment:mirrored:boundingRectPointer:baselineOffsetPointer:drawingContext:] + 5857
6 UIFoundation 0x0000000125ffa518 -[NSCoreTypesetter _stringDrawingCoreTextEngineWithOriginalString:rect:padding:graphicsContext:forceClipping:attributes:stringDrawingOptions:drawingContext:stringDrawingInterface:] + 1266
7 UIFoundation 0x0000000125ff1ea8 __NSStringDrawingEngine + 1882
8 UIFoundation 0x0000000125fef7a8 _NSStringDrawingCore + 173
9 UIFoundation 0x0000000125ff31ae -[NSAttributedString(NSExtendedStringDrawing) drawWithRect:options:context:] + 91
10 UIKitCore 0x0000000123c32a50 -[UILabel _drawTextInRect:baselineCalculationOnly:returningDeviceMetricsOfFirstLine:] + 4359
11 UIKitCore 0x0000000123c39393 -[UILabel _drawTextInRect:baselineCalculationOnly:] + 37
12 UIKitCore 0x0000000123c39c3f -[UILabel _drawTextInRect:] + 257
13 UIKitCore 0x0000000123c38e8a -[UILabel drawTextInRect:] + 615
14 UIKitCore 0x0000000123c39cd2 -[UILabel drawRect:] + 70
15 UIKitCore 0x0000000123d0881d -[UIView(CALayerDelegate) drawLayer:inContext:] + 613
16 QuartzCore 0x0000000114c3cd74 CABackingStoreUpdate_ + 223
17 QuartzCore 0x0000000114df5101 ___ZN2CA5Layer8display_Ev_block_invoke + 53
18 QuartzCore 0x0000000114deb29a -[CALayer _display] + 2114
19 QuartzCore 0x0000000114dfe748 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 464
20 QuartzCore 0x0000000114d0fb0c _ZN2CA7Context18commit_transactionEPNS_11TransactionEdPd + 626
21 QuartzCore 0x0000000114d4769b _ZN2CA11Transaction6commitEv + 735
22 QuartzCore 0x0000000114d48b64 _ZN2CA11Transaction25flush_as_runloop_observerEb + 60
23 CoreFoundation 0x0000000118c2e055 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
24 CoreFoundation 0x0000000118c289c2 __CFRunLoopDoObservers + 515
25 CoreFoundation 0x0000000118c28f0d __CFRunLoopRun + 1161
26 CoreFoundation 0x0000000118c286a7 CFRunLoopRunSpecific + 560
27 GraphicsServices 0x000000011d4df28a GSEventRunModal + 139
28 UIKitCore 0x00000001236d6ad3 -[UIApplication _run] + 994
29 UIKitCore 0x00000001236db9ef UIApplicationMain + 123
30 libswiftUIKit.dylib 0x0000000117366c72 $s5UIKit17UIApplicationMainys5Int32VAD_SpySpys4Int8VGGSgSSSgAJtF + 98
31 MyAppName 0x00000001044eb198 $sSo21UIApplicationDelegateP5UIKitE4mainyyFZ + 104
32 MyAppName 0x00000001044eb127 $s19MyAppName11AppDelegateC5$mainyyFZ + 39
33 MyAppName 0x00000001044eb2c8 main + 24
34 dyld 0x000000010e3e52bf start_sim + 10
35 ??? 0x0000000205ea6310 0x0 + 8689181456
)
libc++abi: terminating with uncaught exception of type NSException
Message from debugger: Terminated due to signal 6

Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan 40]'

This is extremely odd. I practically did nothing with the app. Just fixed a constraint and the app loaded just fine and the constraint had taken the effect. Then simply I re-ran the app and got this error. Don't know how to fix it.
First throw call stack:
(
0 CoreFoundation 0x000000010ea2673b __exceptionPreprocess + 331
1 libobjc.A.dylib 0x000000010da1b735 objc_exception_throw + 48
2 CoreFoundation 0x000000010ea26595 +[NSException raise:format:] + 197
3 QuartzCore 0x000000010ef8a923 _ZN2CA5Layer12set_positionERKNS_4Vec2IdEEb + 141
4 QuartzCore 0x000000010ef79a13 -[CALayer setPosition:] + 57
5 QuartzCore 0x000000010ef7a16f -[CALayer setFrame:] + 561
6 UIKitCore 0x0000000117ebf09e -[UIView(Geometry) setFrame:] + 336
7 List24 0x000000010d0c4364 $S6List2414ViewControllerC05tableB0_12cellForRowAtSo07UITableB4CellCSo0iB0C_10Foundation9IndexPathVtF + 836
8 List24 0x000000010d0c46bb $S6List2414ViewControllerC05tableB0_12cellForRowAtSo07UITableB4CellCSo0iB0C_10Foundation9IndexPathVtFTo + 155
9 UIKitCore 0x0000000117d38c1c -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 771
10 UIKitCore 0x0000000117d391a9 -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 73
11 UIKitCore 0x0000000117d002aa -[UITableView _updateVisibleCellsNow:isRecursive:] + 2863
12 UIKitCore 0x0000000117d20f62 -[UITableView layoutSubviews] + 165
13 UIKitCore 0x0000000117ede749 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1441
14 QuartzCore 0x000000010ef80299 -[CALayer layoutSublayers] + 175
15 QuartzCore 0x000000010ef85153 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 395
16 QuartzCore 0x000000010eefdbb2 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 342
17 QuartzCore 0x000000010ef34e62 _ZN2CA11Transaction6commitEv + 576
18 UIKitCore 0x00000001177e1208 __34-[UIApplication _firstCommitBlock]_block_invoke_2 + 139
19 CoreFoundation 0x000000010e98a2bc __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
20 CoreFoundation 0x000000010e989a70 __CFRunLoopDoBlocks + 336
21 CoreFoundation 0x000000010e9842e4 __CFRunLoopRun + 1284
22 CoreFoundation 0x000000010e983aa1 CFRunLoopRunSpecific + 625
23 GraphicsServices 0x00000001142531dd GSEventRunModal + 62
24 UIKitCore 0x00000001177c6a4f UIApplicationMain + 140
25 List24 0x000000010d0d0f27 main + 71
26 libdyld.dylib 0x000000011116dced start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Nasty Segue Error Message While Using Swift

I am relatively new to Swift and iOS in general. When I create a segue from a button to another view, I get a nasty error message (below). Can someone help me decipher this?
2016-04-17 16:25:49.133 FoodPin[9322:676896] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] instantiated view controller with identifier "UIViewController-u9a-Ka-ctP" from storyboard "Main", but didn't get a UITableView.'
*** First throw call stack:
(
0 CoreFoundation 0x0000000102d58d85 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000104afcdeb objc_exception_throw + 48
2 CoreFoundation 0x0000000102d58cbd +[NSException raise:format:] + 205
3 UIKit 0x000000010396e4e2 -[UITableViewController loadView] + 638
4 UIKit 0x000000010371b560 -[UIViewController loadViewIfRequired] + 138
5 UIKit 0x000000010372193b -[UIViewController __viewWillAppear:] + 120
6 UIKit 0x0000000103751750 -[UINavigationController _startCustomTransition:] + 1203
7 UIKit 0x0000000103761b9b -[UINavigationController _startDeferredTransitionIfNeeded:] + 712
8 UIKit 0x0000000103762d0b -[UINavigationController __viewWillLayoutSubviews] + 57
9 UIKit 0x0000000103911503 -[UILayoutContainerView layoutSubviews] + 248
10 UIKit 0x000000010363b980 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 703
11 QuartzCore 0x0000000108006c00 -[CALayer layoutSublayers] + 146
12 QuartzCore 0x0000000107ffb08e _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
13 QuartzCore 0x0000000107ffaf0c _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
14 QuartzCore 0x0000000107fef3c9 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277
15 QuartzCore 0x000000010801d086 _ZN2CA11Transaction6commitEv + 486
16 QuartzCore 0x000000010801d7f8 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
17 CoreFoundation 0x0000000102c7dc37 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
18 CoreFoundation 0x0000000102c7dba7 __CFRunLoopDoObservers + 391
19 CoreFoundation 0x0000000102c737fb __CFRunLoopRun + 1147
20 CoreFoundation 0x0000000102c730f8 CFRunLoopRunSpecific + 488
21 GraphicsServices 0x00000001073eead2 GSEventRunModal + 161
22 UIKit 0x0000000103580f09 UIApplicationMain + 171
23 FoodPin 0x0000000102b589f2 main + 114
24 libdyld.dylib 0x00000001055c092d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

Store the data dynamically in uitableview using sqlite

Code:
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"]];
Logs:
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

[__NSCFType set]: unrecognized selector sent to instance

I'm having trouble with my prepareForSegue method in my viewController.m.
This is my code:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if([[segue identifier] isEqualToString: #"moveSegue"])
{
SecondViewController *svc = (SecondViewController *)segue.destinationViewController;
svc.finalPercents = [NSNumber numberWithInt:roundf(percents)];
}
And this is the error I get for the line "SecondViewController...segue.destinationViewController;":
[2015-07-19 04:50:51.345 Click[3831:66529] -[__NSCFType set]: unrecognized selector sent to instance 0x7a06d880
2015-07-19 04:50:51.352 Click[3831:66529] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType set]: unrecognized selector sent to instance 0x7a06d880'
*** First throw call stack:
(
0 CoreFoundation 0x00904746 __exceptionPreprocess + 182
1 libobjc.A.dylib 0x0058da97 objc_exception_throw + 44
2 CoreFoundation 0x0090c705 -[NSObject(NSObject) doesNotRecognizeSelector:] + 277
3 CoreFoundation 0x00853287 ___forwarding___ + 1047
4 CoreFoundation 0x00852e4e _CF_forwarding_prep_0 + 14
5 UIFoundation 0x03fc021f __NSStringDrawingEngine + 30451
6 UIFoundation 0x03fb8a0d -[NSString(NSExtendedStringDrawing) drawWithRect:options:attributes:context:] + 171
7 UIKit 0x010fcc78 -[UILabel _drawTextInRect:baselineCalculationOnly:] + 6649
8 UIKit 0x010fa93f -[UILabel drawTextInRect:] + 581
9 UIKit 0x010fcd7d -[UILabel drawRect:] + 98
10 UIKit 0x00f6a079 -[UIView(CALayerDelegate) drawLayer:inContext:] + 519
11 QuartzCore 0x04e9490b -[CALayer drawInContext:] + 118
12 QuartzCore 0x04e94841 _ZL16backing_callbackP9CGContextPv + 96
13 QuartzCore 0x04d757a2 CABackingStoreUpdate_ + 2788
14 QuartzCore 0x04e947d9 ___ZN2CA5Layer8display_Ev_block_invoke + 93
15 QuartzCore 0x04ecb0cc x_blame_allocations + 15
16 QuartzCore 0x04e94635 _ZN2CA5Layer8display_Ev + 1591
17 QuartzCore 0x04e94890 -[CALayer _display] + 33
18 QuartzCore 0x04e93ff6 _ZN2CA5Layer7displayEv + 142
19 QuartzCore 0x04e9486a -[CALayer display] + 33
20 QuartzCore 0x04e88700 _ZN2CA5Layer17display_if_neededEPNS_11TransactionE + 328
21 QuartzCore 0x04e88786 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 38
22 QuartzCore 0x04de4c22 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 284
23 QuartzCore 0x04de60b5 _ZN2CA11Transaction6commitEv + 487
24 QuartzCore 0x04de67cc _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
25 CoreFoundation 0x0082586e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
26 CoreFoundation 0x008257b0 __CFRunLoopDoObservers + 400
27 CoreFoundation 0x0081b1ea __CFRunLoopRun + 1226
28 CoreFoundation 0x0081aa5b CFRunLoopRunSpecific + 443
29 CoreFoundation 0x0081a88b CFRunLoopRunInMode + 123
30 GraphicsServices 0x049b42c9 GSEventRunModal + 192
31 GraphicsServices 0x049b4106 GSEventRun + 104
32 UIKit 0x00ed70b6 UIApplicationMain + 1526
33 Click 0x000a92ea main + 138
34 libdyld.dylib 0x02e96ac9 start + 1
35 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Any suggestions about how to solve this? Thanks.

Resources