I have a code like this:
let myString = "Swift Attributed String"
let myAttribute = [ NSAttributedStringKey.foregroundColor: UIColor.blue , NSAttributedStringKey.writingDirection:(NSWritingDirection.rightToLeft.rawValue|NSWritingDirectionFormatType.override.rawValue)] as [NSAttributedStringKey : Any]
let myAttrString = NSAttributedString(string: myString, attributes: myAttribute)
// set attributed text on a UILabel
self.labelUsername.attributedText = myAttrString
The app is crashing on above line. If I remove NSAttributedStringKey.writingDirection from the attribute dictionary, the crash goes away.
Here's the crash log:
2018-03-20 14:38:59.077 Haraj Swift[90519:25834245] -[__NSCFNumber countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0xb000000000000033
2018-03-20 14:38:59.092 Haraj Swift[90519:25834245] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0xb000000000000033'
*** First throw call stack:
(
0 CoreFoundation 0x000000010ef6434b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010e9c521e objc_exception_throw + 48
2 CoreFoundation 0x000000010efd3f34 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x000000010eee9c15 ___forwarding___ + 1013
4 CoreFoundation 0x000000010eee9798 _CF_forwarding_prep_0 + 120
5 UIFoundation 0x00000001176e13b3 -[NSATSGlyphStorage setGlyphRange:characterRange:] + 2709
6 UIFoundation 0x00000001176dc5ec -[NSATSTypesetter _ctTypesetter] + 287
7 UIFoundation 0x00000001176e6ef7 -[NSATSLineFragment layoutForStartingGlyphAtIndex:characterIndex:minPosition:maxPosition:lineFragmentRect:] + 95
8 UIFoundation 0x00000001176dd540 -[NSATSTypesetter _layoutLineFragmentStartingWithGlyphAtIndex:characterIndex:atPoint:renderingContext:] + 3240
9 UIFoundation 0x00000001176eeb84 -[NSSingleLineTypesetter createRenderingContextForCharacterRange:typesetterBehavior:usesScreenFonts:hasStrongRight:syncDirection:mirrorsTextAlignment:maximumWidth:] + 408
10 UIFoundation 0x0000000117724167 __NSStringDrawingEngine + 27441
11 UIFoundation 0x00000001177263d4 -[NSAttributedString(NSExtendedStringDrawing) boundingRectWithSize:options:context:] + 797
12 UIKit 0x000000010fd1f744 -[UILabel _textRectForBounds:limitedToNumberOfLines:includingShadow:] + 1199
13 UIKit 0x000000010fd1f05b -[UILabel textRectForBounds:limitedToNumberOfLines:] + 68
14 UIKit 0x000000010fd24b7f -[UILabel _intrinsicSizeWithinSize:] + 168
15 UIKit 0x000000010fd24c6c -[UILabel intrinsicContentSize] + 92
16 UIKit 0x00000001104679ed -[UIView(UIConstraintBasedLayout) _generateContentSizeConstraints] + 35
17 UIKit 0x00000001104676ea -[UIView(UIConstraintBasedLayout) _updateContentSizeConstraints] + 494
18 UIKit 0x00000001104714d6 -[UIView(AdditionalLayoutSupport) _updateSystemConstraints] + 66
19 UIKit 0x000000011046ff3e -[UIView(AdditionalLayoutSupport) _sendUpdateConstraintsIfNecessaryForSecondPass:] + 161
20 UIKit 0x000000011047039d -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 860
21 UIKit 0x00000001104702fa -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 697
22 UIKit 0x00000001104702fa -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 697
23 Foundation 0x000000010e4e1bd0 -[NSISEngine withBehaviors:performModifications:] + 155
24 UIKit 0x00000001104705f2 -[UIView(AdditionalLayoutSupport) _recursiveUpdateConstraintsIfNeededCollectingViews:forSecondPass:] + 118
25 UIKit 0x00000001104702fa -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 697
26 UIKit 0x00000001104702fa -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 697
27 Foundation 0x000000010e4e1bd0 -[NSISEngine withBehaviors:performModifications:] + 155
28 UIKit 0x0000000110470c71 __97-[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededPostponeVariableChangeNotifications:]_block_invoke + 91
29 UIKit 0x000000011046fa9b -[UIView(AdditionalLayoutSupport) _withUnsatisfiableConstraintsLoggingSuspendedIfEngineDelegateExists:] + 117
30 UIKit 0x0000000110470757 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededPostponeVariableChangeNotifications:] + 181
31 UIKit 0x000000011047184d -[UIView(AdditionalLayoutSupport) _updateConstraintsAtEngineLevelIfNeededPostponeVariableChangeNotifications:] + 356
32 UIKit 0x000000010fb4b922 -[UIView(Hierarchy) _updateConstraintsAsNecessaryAndApplyLayoutFromEngine] + 159
33 UIKit 0x000000010fb5cf50 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1237
34 QuartzCore 0x0000000117054cc4 -[CALayer layoutSublayers] + 146
35 QuartzCore 0x0000000117048788 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
36 QuartzCore 0x0000000117048606 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
37 QuartzCore 0x0000000116fd6680 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 280
38 QuartzCore 0x0000000117003767 _ZN2CA11Transaction6commitEv + 475
39 QuartzCore 0x00000001170040d7 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 113
40 CoreFoundation 0x000000010ef08e17 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
41 CoreFoundation 0x000000010ef08d87 __CFRunLoopDoObservers + 391
42 CoreFoundation 0x000000010eeedb9e __CFRunLoopRun + 1198
43 CoreFoundation 0x000000010eeed494 CFRunLoopRunSpecific + 420
44 GraphicsServices 0x0000000116f37a6f GSEventRunModal + 161
45 UIKit 0x000000010fa98964 UIApplicationMain + 159
46 Haraj Swift 0x000000010de9e8a7 main + 55
47 libdyld.dylib 0x0000000112fe168d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Try using an array of NSWritingDirection
let myString = "Swift Attributed String"
let myAttrString = NSAttributedString(string: myString, attributes: [.foregroundColor : UIColor.blue, .writingDirection: [NSWritingDirection.rightToLeft.rawValue]])
self.label.attributedText = myAttrString
Let me know if you still face any issues.
According to documentation, you have to use a NSNumber for indicate the value
Array NSNumber Values
Writing Direction Constants
0 -> NSWritingDirectionLeftToRight | NSTextWritingDirectionEmbedding
1 -> NSWritingDirectionRightToLeft | NSTextWritingDirectionEmbedding
2 -> NSWritingDirectionLeftToRight | NSTextWritingDirectionOverride
3 -> NSWritingDirectionRightToLeft | NSTextWritingDirectionOverride
So, you can do that by this way
let myString = "Swift Attributed String"
let attr:[NSAttributedStringKey: Any] = [.foregroundColor: UIColor.blue, .writingDirection: [NSNumber(integerLiteral: 3)]]
let myAttrString = NSAttributedString(string: myString, attributes:attr)
self.label.attributedText = myAttrString
Related
I am trying to save the JSON response in the realm using Alamofire and ObjectMapper. And I am getting this error:
* Terminating app due to uncaught exception 'RLMException', reason: 'Index 0 is out of bounds (must be less than 0).'
* First throw call stack:
(
0 CoreFoundation 0x00000001113e18db exceptionPreprocess + 331
1 libobjc.A.dylib 0x0000000110984ac5 objc_exception_throw + 48
2 Realm 0x000000010e30efee _Z20RLMThrowResultsErrorP8NSString + 670
3 Realm 0x000000010e310206 _ZL25translateRLMResultsErrorsIZ28-[RLMResults objectAtIndex:]E3$_6EDaOT_P8NSString + 118
4 Realm 0x000000010e310136 -[RLMResults objectAtIndex:] + 102
5 RealmSwift 0x000000010fa37436 $s10RealmSwift7ResultsCyxSicig + 262
6 App Name 0x000000010c0e9155 $s24Mahalaxmi_Life_Insurance12CalculatorVCC14collectionView_22numberOfItemsInSectionSiSo012UICollectionG0C_SitF + 197
7 App Name 0x000000010c0e934c $s24Mahalaxmi_Life_Insurance12CalculatorVCC14collectionView_22numberOfItemsInSectionSiSo012UICollectionG0C_SitFTo + 76
8 UIKitCore 0x00000001155dd2c3 -[UICollectionViewData _updateItemCounts] + 409
9 UIKitCore 0x00000001155dfb4f -[UICollectionViewData numberOfSections] + 22
10 UIKitCore 0x00000001155eafbe -[UICollectionViewFlowLayout _getSizingInfosWithExistingSizingDictionary:] + 511
11 UIKitCore 0x00000001155ed228 -[UICollectionViewFlowLayout _fetchItemsInfoForRect:] + 231
12 UIKitCore 0x00000001155e5dc1 -[UICollectionViewFlowLayout prepareLayout] + 246
13 UIKitCore 0x00000001155dd5a8 -[UICollectionViewData _prepareToLoadData] + 212
14 UIKitCore 0x00000001155ddfb4 -[UICollectionViewData validateLayoutInRect:] + 53
15 UIKitCore 0x00000001155acec6 -[UICollectionView layoutSubviews] + 261
16 UIKitCore 0x000000011620ae69 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1417
17 QuartzCore 0x000000010de75d22 -[CALayer layoutSublayers] + 173
18 QuartzCore 0x000000010de7a9fc _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 396
19 QuartzCore 0x000000010de86d58 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 72
20 QuartzCore 0x000000010ddf624a _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 328
21 QuartzCore 0x000000010de2d606 _ZN2CA11Transaction6commitEv + 610
22 UIKitCore 0x0000000115d5399c _afterCACommitHandler + 245
23 CoreFoundation 0x00000001113482c7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 23
24 CoreFoundation 0x000000011134278e __CFRunLoopDoObservers + 430
25 CoreFoundation 0x0000000111342e01 __CFRunLoopRun + 1505
26 CoreFoundation 0x00000001113424d2 CFRunLoopRunSpecific + 626
27 GraphicsServices 0x000000011971b2fe GSEventRunModal + 65
28 UIKitCore 0x0000000115d2bfc2 UIApplicationMain + 140
29 App Name 0x000000010c0a976b main + 75
30 libdyld.dylib 0x000000011238e541 start + 1
31 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
JSON Response is like this
["Title": [ "S", "Y", "H", "Q", "M" ]]
My Model is like this
class TermList : Object, Mappable {
#objc dynamic var mainTerm : String?
var payingTerm = [String]?
required convenience init?(map: Map) {
self.init()
}
func mapping(map: Map) {
mainTerm <- map["MainTerm"]
payingTerm <- map["PayingTerm"]
}
}
I have been developing framework, I have used tab menu using carbonKit cocoapods, Now i'm trying to navigate UIVIewController xib.
When UITabBarController loaded the carbonkit menu default tab menu will be called.
Here is the code used for load xib UIViewcontroller
public func carbonTabSwipeNavigation(_ carbonTabSwipeNavigation: CarbonTabSwipeNavigation, viewControllerAt index: UInt) -> UIViewController {
print("called carbonkit")
print("carbon kit index 0 called")
return (UINib(nibName: "FirstViewController", bundle: Bundle(for: FirstViewController.self)).instantiate(withOwner: nil, options: nil).first as? FirstViewController)!
}
Here is the console output:
Called tab
called carbonkit
carbon kit index 0 called
2019-11-12 22:13:02.350434+0530 A8FlowSampleApp[41059:1971714] ***
Terminating app due to uncaught exception 'NSUnknownKeyException',
reason: '[<NSObject 0x600000b1c8b0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key view.'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff23c4f02e __exceptionPreprocess + 350
1 libobjc.A.dylib 0x00007fff50b97b20 objc_exception_throw + 48
2 CoreFoundation 0x00007fff23c4ebf9 -[NSException raise] + 9
3 Foundation 0x00007fff256f2ef3 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 325
4 UIKitCore 0x00007fff474b9a52 -[UIRuntimeOutletConnection connect] + 109
5 CoreFoundation 0x00007fff23c3b052 -[NSArray makeObjectsPerformSelector:] + 242
6 UIKitCore 0x00007fff474b6bfa -[UINib instantiateWithOwner:options:] + 2190
7 A8Flow 0x0000000104db51d8 $s6A8Flow6MyTaskC24carbonTabSwipeNavigation_16viewControllerAtSo06UIViewJ0CSo06CarbonfgH0C_SutF + 1016
8 A8Flow 0x0000000104db546d $s6A8Flow6MyTaskC24carbonTabSwipeNavigation_16viewControllerAtSo06UIViewJ0CSo06CarbonfgH0C_SutFTo + 77
9 CarbonKit 0x00000001048c1d31 -[CarbonTabSwipeNavigation viewControllerAtIndex:] + 593
10 CarbonKit 0x00000001048c18fb -[CarbonTabSwipeNavigation loadFirstViewController] + 411
11 CarbonKit 0x00000001048bc90e -[CarbonTabSwipeNavigation initWithItems:delegate:] + 350
12 A8Flow 0x0000000104db69f2 $sSo24CarbonTabSwipeNavigationC5items8delegateABSayypGSg_yptcfcTO + 242
13 A8Flow 0x0000000104db4bc2 $sSo24CarbonTabSwipeNavigationC5items8delegateABSayypGSg_yptcfC + 50
14 A8Flow 0x0000000104db40ba $s6A8Flow6MyTaskC11viewDidLoadyyF + 378
15 A8Flow 0x0000000104db4dcb $s6A8Flow6MyTaskC11viewDidLoadyyFTo + 43
16 UIKitCore 0x00007fff471cdb45 -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 83
17 UIKitCore 0x00007fff471d2a9e -[UIViewController loadViewIfRequired] + 1084
18 UIKitCore 0x00007fff47136b8c -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 160
19 UIKitCore 0x00007fff47136e8c -[UINavigationController _startTransition:fromViewController:toViewController:] + 140
20 UIKitCore 0x00007fff47137d56 -[UINavigationController _startDeferredTransitionIfNeeded:] + 868
21 UIKitCore 0x00007fff471390c1 -[UINavigationController __viewWillLayoutSubviews] + 150
22 UIKitCore 0x00007fff47119ef7 -[UILayoutContainerView layoutSubviews] + 217
23 UIKitCore 0x00007fff47d34cfd -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2478
24 QuartzCore 0x00007fff2b138d41 -[CALayer layoutSublayers] + 255
25 QuartzCore 0x00007fff2b13ef33 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 517
26 QuartzCore 0x00007fff2b14a86a _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 80
27 QuartzCore 0x00007fff2b0917c8 _ZN2CA7Context18commit_transactionEPNS_11TransactionEd + 324
28 QuartzCore 0x00007fff2b0c6ad1 _ZN2CA11Transaction6commitEv + 643
29 UIKitCore 0x00007fff47867481 __34-[UIApplication _firstCommitBlock]_block_invoke_2 + 81
30 CoreFoundation 0x00007fff23bb204c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
31 CoreFoundation 0x00007fff23bb17b8 __CFRunLoopDoBlocks + 312
32 CoreFoundation 0x00007fff23bac644
__CFRunLoopRun + 1284
33 CoreFoundation 0x00007fff23babe16
CFRunLoopRunSpecific + 438
34 GraphicsServices 0x00007fff38438bb0
GSEventRunModal + 65
35 UIKitCore 0x00007fff4784fb68
UIApplicationMain + 1621
36 A8FlowSampleApp 0x000000010458a6bb main + 75
37 libdyld.dylib 0x00007fff51a1dc25 start + 1
38 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type
NSException
(lldb)
Any help much appreciated pls.. tried lot ways to achieve it but could not make it.
Fixed myself
func firstView() -> UIViewController {
let cont = FirstViewController()
self.tabContView?.addChild(cont)
self.tabContView?.view.addSubview(cont.view)
cont.didMove(toParent: tabContView)
return cont
}
public func carbonTabSwipeNavigation(_ carbonTabSwipeNavigation: CarbonTabSwipeNavigation, viewControllerAt index: UInt) -> UIViewController {
print("called carbonkit")
print("carbon kit index 0 called")
return firstView()
}
There is a group of crashes reported by crittercism.
I've never reproduced it but there're about 50 times from different users in 1 weeks.
21
XXApp 0x0000000100129fb0 -[NSString(XXFormat) attributedStringFromHTMLByFont:] (NSString+XXFormat.m:15) was crashed.
Following is The line 15 code in NSString+XXFormat.m:
NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithData:[self dataUsingEncoding:NSUTF8StringEncoding]
options:#{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,
NSCharacterEncodingDocumentAttribute: #(NSUTF8StringEncoding)}
documentAttributes:nil error:nil];
Name: NSRangeException
Reason: *** -[__NSArrayM objectAtIndex:]: index 3 beyond bounds [0 .. 2]
Stack:
0
CoreFoundation 0x0000000183a0c2d8 __exceptionPreprocess + 128
1
libobjc.A.dylib 0x00000001952380e4 objc_exception_throw + 56
2
CoreFoundation 0x00000001838ef85c -[__NSArrayM objectAtIndex:] + 260
3
UIKit 0x0000000188575a94 -[UITableView cellForRowAtIndexPath:] + 212
4
UIKit 0x000000018873fa00 -[UITableViewWrapperView gestureRecognizerShouldBegin:] + 284
5
UIKit 0x00000001885e2c34 -[UIGestureRecognizer _shouldBegin] + 1072
6
UIKit 0x000000018847b340 -[UIGestureRecognizer setState:] + 428
7
UIKit 0x00000001885f4fdc -[UIScrollViewPanGestureRecognizer touchesMoved:withEvent:] + 100
8
UIKit 0x000000018847a6d8 -[UIWindow _sendGesturesForEvent:] + 592
9
UIKit 0x0000000188479f50 -[UIWindow sendEvent:] + 656
10
UIKit 0x000000018844d18c -[UIApplication sendEvent:] + 260
11
UIKit 0x00000001886ee324 _UIApplicationHandleEventFromQueueEvent + 15420
12
UIKit 0x000000018844b6a0 _UIApplicationHandleEventQueue + 1712
13
CoreFoundation 0x00000001839c4240 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 20
14
CoreFoundation 0x00000001839c359c __CFRunLoopDoSources0 + 444
15
CoreFoundation 0x00000001839c1594 __CFRunLoopRun + 708
16
CoreFoundation 0x00000001838ed2d4 CFRunLoopRunSpecific + 392
17
UIFoundation 0x0000000191850c10 -[NSHTMLReader _loadUsingWebKit] + 1984
18
UIFoundation 0x0000000191851fd0 -[NSHTMLReader attributedString] + 28
19
UIFoundation 0x00000001917ef23c _NSReadAttributedStringFromURLOrData + 5800
20
UIFoundation 0x00000001917edad8 -[NSAttributedString(NSAttributedStringUIFoundationAdditions) initWithData:options:documentAttributes:error:] + 144
21
XXApp 0x0000000100129fb0 -[NSString(XXFormat) attributedStringFromHTMLByFont:] (NSString+XXFormat.m:15)
22
XXApp 0x0000000100112f64 -[XXNews(Peer) attributedContent] (XXNews+Peer.m:56)
23
XXApp 0x00000001000fc854 -[XXWidgetNewsCell setWidget:] (XXWidgetNewsCell.m:53)
24
XXApp 0x0000000100116ba4 -[XXTimeLineTableViewController tableView:cellForRowAtIndexPath:] (XXTimeLineTableViewController.m:231)
25
UIKit 0x000000018874da68 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 540
26
UIKit 0x0000000188741890 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2360
27
UIKit 0x000000018852d268 -[UITableView layoutSubviews] + 168
28
UIKit 0x0000000188449760 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 576
29
QuartzCore 0x0000000187d91e1c -[CALayer layoutSublayers] + 148
30
QuartzCore 0x0000000187d8c884 CA::Layer::layout_if_needed() + 316
31
QuartzCore 0x0000000187d8c728 CA::Layer::layout_and_display_if_needed() + 28
32
QuartzCore 0x0000000187d8bebc CA::Context::commit_transaction() + 272
33
QuartzCore 0x0000000187d8bc3c CA::Transaction::commit() + 524
34
QuartzCore 0x0000000187d85364 CA::Transaction::observer_callback() + 76
35
CoreFoundation 0x00000001839c42a4 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 28
36
CoreFoundation 0x00000001839c1230 __CFRunLoopDoObservers + 356
37
CoreFoundation 0x00000001839c1610 __CFRunLoopRun + 832
38
CoreFoundation 0x00000001838ed2d4 CFRunLoopRunSpecific + 392
39
GraphicsServices 0x000000018d1036fc GSEventRunModal + 164
40
UIKit 0x00000001884b2fac UIApplicationMain + 1484
41
XXApp 0x0000000100101280 main (main.m:14)
42
libdyld.dylib 0x00000001958b6a08 start + 0
It's not the snippet that you have shared here that is causing the issue but you are trying to access to in-existent element in an array :
Name: NSRangeException
Reason: *** -[__NSArrayM objectAtIndex:]: index 3 beyond bounds [0 .. 2]
the array has bounds [0 .. 2] and you try to access to index 3 that's not existent element
make sure in your method cellForRowAtIndexPath you are not bypassing the index of your NSArray
When I'm trying to make a social media-like app using Parse, I get the following error when trying to go to the section to compose a "sweet". I'm trying to recreate what is in this video: (https://youtu.be/Q6kTw_cK3zY), and this is the error I am getting in the console output :
*** First throw call stack:
(
0 CoreFoundation 0x0000000105cfdc65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000107868bb7 objc_exception_throw + 45
2 CoreFoundation 0x0000000105cfd8a9 -[NSException raise] + 9
3 Foundation 0x000000010611bb53 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 259
4 CoreFoundation 0x0000000105c45d50 -[NSArray makeObjectsPerformSelector:] + 224
5 UIKit 0x000000010687452b -[UINib instantiateWithOwner:options:] + 1506
6 UIKit 0x00000001066cc718 -[UIViewController _loadViewFromNibNamed:bundle:] + 242
7 UIKit 0x00000001066ccd08 -[UIViewController loadView] + 109
8 UIKit 0x00000001066ccf79 -[UIViewController loadViewIfRequired] + 75
9 UIKit 0x00000001066cd40e -[UIViewController view] + 27
10 UIKit 0x00000001066f2297 -[UINavigationController _startCustomTransition:] + 633
11 UIKit 0x00000001066fe3bf -[UINavigationController _startDeferredTransitionIfNeeded:] + 386
12 UIKit 0x00000001066fef0e -[UINavigationController __viewWillLayoutSubviews] + 43
13 UIKit 0x0000000106849715 -[UILayoutContainerView layoutSubviews] + 202
14 UIKit 0x000000010661ca2b -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 536
15 QuartzCore 0x00000001058caec2 -[CALayer layoutSublayers] + 146
16 QuartzCore 0x00000001058bf6d6 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
17 QuartzCore 0x00000001058bf546 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
18 QuartzCore 0x000000010582b886 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
19 QuartzCore 0x000000010582ca3a _ZN2CA11Transaction6commitEv + 462
20 UIKit 0x0000000106599626 _UIApplicationHandleEventQueue + 2140
21 CoreFoundation 0x0000000105c31431 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
22 CoreFoundation 0x0000000105c272fd __CFRunLoopDoSources0 + 269
23 CoreFoundation 0x0000000105c26934 __CFRunLoopRun + 868
24 CoreFoundation 0x0000000105c26366 CFRunLoopRunSpecific + 470
25 GraphicsServices 0x0000000108c02a3e GSEventRunModal + 161
26 UIKit 0x000000010659c900 UIApplicationMain + 1282
27 switter 0x0000000104834767 main + 135
28 libdyld.dylib 0x000000010883d145 start + 1
29 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
I am facing a strange issue in one of my View Controllers, Every thing works fine and loads fine but when ever i set a Value to the View i get an Exception related to layer. However i am not setting any properties to the Layer either in Interface Builder or in the Code. Below is the Log that i receive which right now makes no sense to me
-[__NSCFNumber length]: unrecognized selector sent to instance 0x923a4e0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber length]: unrecognized selector sent to instance 0x923a4e0'
*** First throw call stack:
(
0 CoreFoundation 0x01ef31e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x01bf08e5 objc_exception_throw + 44
2 CoreFoundation 0x01f90243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x01ee350b ___forwarding___ + 1019
4 CoreFoundation 0x01ee30ee _CF_forwarding_prep_0 + 14
5 UIKit 0x00a6d463 -[UILabel _shadow] + 45
6 UIKit 0x00a6e8c2 -[UILabel drawTextInRect:] + 70
7 UIKit 0x00a70dfc -[UILabel drawRect:] + 98
8 UIKit 0x0091f453 -[UIView(CALayerDelegate) drawLayer:inContext:] + 504
9 QuartzCore 0x00213f39 -[CALayer drawInContext:] + 123
10 QuartzCore 0x00213e6a _ZL16backing_callbackP9CGContextPv + 96
11 QuartzCore 0x001024fc CABackingStoreUpdate_ + 2656
12 QuartzCore 0x00213e02 ___ZN2CA5Layer8display_Ev_block_invoke + 93
13 QuartzCore 0x002482d7 x_blame_allocations + 15
14 QuartzCore 0x00213c6d _ZN2CA5Layer8display_Ev + 1519
15 QuartzCore 0x00213eb9 -[CALayer _display] + 33
16 QuartzCore 0x00213676 _ZN2CA5Layer7displayEv + 144
17 QuartzCore 0x00213e93 -[CALayer display] + 33
18 QuartzCore 0x00210fb7 -[CALayer displayIfNeeded] + 57
19 QuartzCore 0x002113b1 -[CALayer renderInContext:] + 192
20 QuartzCore 0x00213376 -[CALayer _renderSublayersInContext:] + 413
21 QuartzCore 0x002118bc -[CALayer renderInContext:] + 1483
22 QuartzCore 0x00213376 -[CALayer _renderSublayersInContext:] + 413
23 QuartzCore 0x002118bc -[CALayer renderInContext:] + 1483
24 QuartzCore 0x00213376 -[CALayer _renderSublayersInContext:] + 413
25 QuartzCore 0x002118bc -[CALayer renderInContext:] + 1483
26 SilverStar 0x00011fad -[UIView(ABExtras) imageInNavController:] + 525
27 SilverStar 0x00013005 -[CubeNavigationController pushViewController:animated:] + 549
28 SilverStar 0x0000c936 -[MSArticleViewController detailsbuttonTapped:] + 438
29 libobjc.A.dylib 0x01c02880 -[NSObject performSelector:withObject:withObject:] + 77
30 UIKit 0x008b23b9 -[UIApplication sendAction:to:from:forEvent:] + 108
31 UIKit 0x008b2345 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
32 UIKit 0x009b3bd1 -[UIControl sendAction:to:forEvent:] + 66
33 UIKit 0x009b3fc6 -[UIControl _sendActionsForEvents:withEvent:] + 577
34 UIKit 0x009b3243 -[UIControl touchesEnded:withEvent:] + 641
35 UIKit 0x00c482e3 _UIGestureRecognizerUpdate + 7166
36 UIKit 0x008f1a5a -[UIWindow _sendGesturesForEvent:] + 1291
37 UIKit 0x008f2971 -[UIWindow sendEvent:] + 1021
38 UIKit 0x008c45f2 -[UIApplication sendEvent:] + 242
39 UIKit 0x008ae353 _UIApplicationHandleEventQueue + 11455
40 CoreFoundation 0x01e7c77f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
41 CoreFoundation 0x01e7c10b __CFRunLoopDoSources0 + 235
42 CoreFoundation 0x01e991ae __CFRunLoopRun + 910
43 CoreFoundation 0x01e989d3 CFRunLoopRunSpecific + 467
44 CoreFoundation 0x01e987eb CFRunLoopRunInMode + 123
45 GraphicsServices 0x036c25ee GSEventRunModal + 192
46 GraphicsServices 0x036c242b GSEventRun + 104
47 UIKit 0x008b0f9b UIApplicationMain + 1225
Note: I am not sure which Code Section you might require. So, Let me know i will add in the Question here
You are passing NSNumber instead of NSString. Try this:
NSString *myString = [aNumber stringValue]; // aNumber is a NSNumber
self.label.text = myString
Hope this helps.. :)