-[_SwiftValue unsignedIntegerValue]: unrecognized selector sent to instance 0x608000243d50 (lldb) - swift

I finished migrating my application to swift3 but this section keeps yielding is causing problems.
override func viewWillAppear(_ animated: Bool)
{
super.viewWillAppear(animated)
self.navigationController?.setNavigationBarHidden(false, animated: animated)
self.navigationItem.title = artworkTitle
let title = "<center><span style=\"font-size: 17px;font-weight:lighter;font-family:Avenir-Book;\">" + artworkCaption + "</span></center>"
artworkImageView.image = UIImage(named: artworkImagePath)
artworkCaptionView.attributedText = title.html2AttStr
}
Important Console Parts
-[_SwiftValue unsignedIntegerValue]: unrecognized selector sent to instance 0x608000243d50
terminating with uncaught exception of type NSException
(lldb)
extension String
{
var html2AttStr:NSAttributedString
{
let contents: NSMutableAttributedString?
do {
let attrTextStyle = NSMutableParagraphStyle()
attrTextStyle.alignment = NSTextAlignment.center
contents = try NSMutableAttributedString(data: data(using: String.Encoding.utf8)!, options:[NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute: String.Encoding.utf8], documentAttributes: nil)
} catch _ {
contents = nil
}
Console
0 CoreFoundation 0x000000010b70934b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010ad7521e objc_exception_throw + 48
2 CoreFoundation 0x000000010b778f34 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x000000010b68ec15 ___forwarding___ + 1013
4 CoreFoundation 0x000000010b68e798 _CF_forwarding_prep_0 + 120
5 UIFoundation 0x0000000114565953 -[NSHTMLReader _loadUsingWebKit] + 1329
6 UIFoundation 0x0000000114566f15 -[NSHTMLReader attributedString] + 22
7 UIFoundation 0x00000001144fd45c _NSReadAttributedStringFromURLOrData + 5779
8 UIFoundation 0x00000001144fbd35 -[NSAttributedString(NSAttributedStringUIFoundationAdditions) initWithData:options:documentAttributes:error:] + 115
9 pg 0x000000010a39fe1d _TTOFCSo25NSMutableAttributedStringcfzT4dataV10Foundation4Data7optionsGVs10DictionarySSP__18documentAttributesGSqGVs33AutoreleasingUnsafeMutablePointerGSqCSo12NSDictionary____S_ + 173
10 pg 0x000000010a39fba4 _TFCSo25NSMutableAttributedStringCfzT4dataV10Foundation4Data7optionsGVs10DictionarySSP__18documentAttributesGSqGVs33AutoreleasingUnsafeMutablePointerGSqCSo12NSDictionary____S_ + 100
11 pg 0x000000010a39f96a _TFE2pgSSg11html2AttStrCSo18NSAttributedString + 458
12 pg 0x000000010a3a901d _TFC2pg21ViewControllerArtwork14viewWillAppearfSbT_ + 1197
13 pg 0x000000010a3a90b1 _TToFC2pg21ViewControllerArtwork14viewWillAppearfSbT_ + 49
14 UIKit 0x000000010c642de3 -[UIViewController _setViewAppearState:isAnimating:] + 692
15 UIKit 0x000000010c6434f3 -[UIViewController __viewWillAppear:] + 147
16 UIKit 0x000000010c67e1a3 -[UINavigationController _startTransition:fromViewController:toViewController:] + 890
17 UIKit 0x000000010c67f0b9 -[UINavigationController _startDeferredTransitionIfNeeded:] + 874
18 UIKit 0x000000010c68019b -[UINavigationController __viewWillLayoutSubviews] + 58
19 UIKit 0x000000010c8771b7 -[UILayoutContainerView layoutSubviews] + 223
20 UIKit 0x000000010c560344 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1237
21 QuartzCore 0x000000010c312cdc -[CALayer layoutSublayers] + 146
22 QuartzCore 0x000000010c3067a0 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
23 QuartzCore 0x000000010c30661e _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
24 QuartzCore 0x000000010c29462c _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 280
25 QuartzCore 0x000000010c2c1713 _ZN2CA11Transaction6commitEv + 475
26 UIKit 0x000000010c495067 _UIApplicationFlushRunLoopCATransactionIfTooLate + 206
27 UIKit 0x000000010cca4b30 __handleEventQueue + 5672
28 CoreFoundation 0x000000010b6ae311 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
29 CoreFoundation 0x000000010b69359c __CFRunLoopDoSources0 + 556
30 CoreFoundation 0x000000010b692a86 __CFRunLoopRun + 918
31 CoreFoundation 0x000000010b692494 CFRunLoopRunSpecific + 420
32 GraphicsServices 0x0000000111084a6f GSEventRunModal + 161
33 UIKit 0x000000010c49bf34 UIApplicationMain + 159
34 pg 0x000000010a3acaaf main + 111
35 libdyld.dylib 0x000000011233668d start + 1
36 ??? 0x0000000000000001 0x0 + 1
libc++abi.dylib: terminating with uncaught exception of type NSException

I remember reading on Apple's Swift blog that if you get unrecognized selector errors, it means that the auto-wrapping of Swift structs are causing issues. Most likely it is wrapping String.Encoding instead of converting it to an NSNumber (what the Objective-C code behind NSMutableAttributedString is expecting).
Try replacing NSCharacterEncodingDocumentAttribute: String.Encoding.utf8 with NSCharacterEncodingDocumentAttribute: String.Encoding.utf8.rawValue

Related

Why app crashes with [NSObject(NSObject) doesNotRecognizeSelector:]?

The app sometimes crashes with [NSObject(NSObject) doesNotRecognizeSelector:], the selector being [UIImageView setImage:].
I captured it by setting an exception breakpoint and the crash happens when setting an UIImageView.image in prepareForReuse of a UICollectionViewCell:
class MyCell: UICollectionViewCell {
var coverImageView = UIImageView()
...
override func prepareForReuse() {
super.prepareForReuse()
coverImageView.image = nil
}
}
The prepareForReuse is called then the cell is instantiated:
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = myCollectionView.dequeueReusableCell(withReuseIdentifier: "myReuseID", for: indexPath) as! MyCell
...
}
Why is that happening?
Also I cannot load the quick look data view for the UIImageView so maybe the object has been released?
The error messages in console are:
2017-01-21 15:56:19.653 MyApp[4873:20387361] -[__NSMallocBlock__ size]: unrecognized selector sent to instance 0x608000880aa0
2017-01-21 15:56:37.697 MyApp[4873:20387361] invalid mode 'kCFRunLoopCommonModes' provided to CFRunLoopRunSpecific - break on _CFRunLoopError_RunCalledWithInvalidMode to debug. This message will only appear once per execution.
2017-01-21 15:56:38.847 MyApp[4873:20617657] [Optimizely Logging]: Successfully saved data file to disk. Code revision is 229
2017-01-21 15:56:42.723 MyApp[4873:20387361] [Optimizely Logging]: (ERROR) NSInvalidArgumentException: Stack Trace:
(
0 CoreFoundation 0x000000010f587d4b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010ef6121e objc_exception_throw + 48
2 CoreFoundation 0x000000010f5f7f04 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x000000010f50d005 ___forwarding___ + 1013
4 CoreFoundation 0x000000010f50cb88 _CF_forwarding_prep_0 + 120
5 UIKit 0x000000010ba5e20f -[UIImageView _updateImageViewForOldImage:newImage:] + 297
6 UIKit 0x000000010ba59950 -[UIImageView setImage:] + 391
7 MyApp 0x000000010945e0d8 _TFC6MyApp23MyCell15prepareForReusefT_T_ + 136
8 MyApp 0x000000010945e112 _TToFC6MyApp23MyCell15prepareForReusefT_T_ + 34
9 UIKit 0x000000010c19aed1 -[UICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:viewCategory:] + 773
10 UIKit 0x000000010c19b8ea -[UICollectionView dequeueReusableCellWithReuseIdentifier:forIndexPath:] + 169
11 MyApp 0x00000001095bdee2 _TFC6MyApp23MyViewController14collectionViewfTCSo16UICollectionView13cellForItemAtV10Foundation9IndexPath_CSo20UICollectionViewCell + 594
12 MyApp 0x00000001095be747 _TToFC6MyApp23MyViewController14collectionViewfTCSo16UICollectionView13cellForItemAtV10Foundation9IndexPath_CSo20UICollectionViewCell + 87
13 UIKit 0x000000010c18675f -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:isFocused:notify:] + 467
14 UIKit 0x000000010c186586 -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:] + 35
15 UIKit 0x000000010c18ba5e -[UICollectionView _updateVisibleCellsNow:] + 4803
16 UIKit 0x000000010c191725 -[UICollectionView layoutSubviews] + 313
17 UIKit 0x000000010b90dab8 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1237
18 QuartzCore 0x000000010d558bf8 -[CALayer layoutSublayers] + 146
19 QuartzCore 0x000000010d54c440 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
20 QuartzCore 0x000000010d54c2be _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
21 QuartzCore 0x000000010d4da318 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 280
22 QuartzCore 0x000000010d5073ff _ZN2CA11Transaction6commitEv + 475
23 QuartzCore 0x000000010d507d6f _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 113
24 CoreFoundation 0x000000010f52c267 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
25 CoreFoundation 0x000000010f52c1d7 __CFRunLoopDoObservers + 391
26 CoreFoundation 0x000000010f510f8e __CFRunLoopRun + 1198
27 CoreFoundation 0x000000010f510884 CFRunLoopRunSpecific + 420
28 GraphicsServices 0x0000000112b77a6f GSEventRunModal + 161
29 UIKit 0x000000010b848c68 UIApplicationMain + 159
30 MyApp 0x00000001092f5a7f main + 111
31 libdyld.dylib 0x00000001115b568d start + 1
)
2017-01-21 15:56:42.725 MyApp[4873:20387361] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSMallocBlock__ size]: unrecognized selector sent to instance 0x608000880aa0'
*** First throw call stack:
(
0 CoreFoundation 0x000000010f587d4b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010ef6121e objc_exception_throw + 48
2 CoreFoundation 0x000000010f5f7f04 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x000000010f50d005 ___forwarding___ + 1013
4 CoreFoundation 0x000000010f50cb88 _CF_forwarding_prep_0 + 120
5 UIKit 0x000000010ba5e20f -[UIImageView _updateImageViewForOldImage:newImage:] + 297
6 UIKit 0x000000010ba59950 -[UIImageView setImage:] + 391
7 MyApp 0x000000010945e0d8 _TFC6MyApp23MyCell15prepareForReusefT_T_ + 136
8 MyApp 0x000000010945e112 _TToFC6MyApp23MyCell15prepareForReusefT_T_ + 34
9 UIKit 0x000000010c19aed1 -[UICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:viewCategory:] + 773
10 UIKit 0x000000010c19b8ea -[UICollectionView dequeueReusableCellWithReuseIdentifier:forIndexPath:] + 169
11 MyApp 0x00000001095bdee2 _TFC6MyApp23MyViewController14collectionViewfTCSo16UICollectionView13cellForItemAtV10Foundation9IndexPath_CSo20UICollectionViewCell + 594
12 MyApp 0x00000001095be747 _TToFC6MyApp23MyViewController14collectionViewfTCSo16UICollectionView13cellForItemAtV10Foundation9IndexPath_CSo20UICollectionViewCell + 87
13 UIKit 0x000000010c18675f -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:isFocused:notify:] + 467
14 UIKit 0x000000010c186586 -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:] + 35
15 UIKit 0x000000010c18ba5e -[UICollectionView _updateVisibleCellsNow:] + 4803
16 UIKit 0x000000010c191725 -[UICollectionView layoutSubviews] + 313
17 UIKit 0x000000010b90dab8 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1237
18 QuartzCore 0x000000010d558bf8 -[CALayer layoutSublayers] + 146
19 QuartzCore 0x000000010d54c440 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
20 QuartzCore 0x000000010d54c2be _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
21 QuartzCore 0x000000010d4da318 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 280
22 QuartzCore 0x000000010d5073ff _ZN2CA11Transaction6commitEv + 475
23 QuartzCore 0x000000010d507d6f _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 113
24 CoreFoundation 0x000000010f52c267 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
25 CoreFoundation 0x000000010f52c1d7 __CFRunLoopDoObservers + 391
26 CoreFoundation 0x000000010f510f8e __CFRunLoopRun + 1198
27 CoreFoundation 0x000000010f510884 CFRunLoopRunSpecific + 420
28 GraphicsServices 0x0000000112b77a6f GSEventRunModal + 161
29 UIKit 0x000000010b848c68 UIApplicationMain + 159
30 MyApp 0x00000001092f5a7f main + 111
31 libdyld.dylib 0x00000001115b568d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
I think the problem is that you are not calling the designated initializer of UIImageView, therefore its image property is not properly initialized and trying to assign to it crashes the app:
-[NSMallocBlock size]: unrecognized selector sent to instance 0x608000880aa0
The method tries to call the size method on the old image but the old image was set to some random memory address.
To fix it, initialize UIImageView properly using the designated initializer:
var coverImageView = UIImageView(image: nil)

Logout Button crash

I just implemented a logout button on my HeaderView sector. But somehow I keep getting this crash from Xcode.
I feel like this is somehow related to my func logoutBtnClicked(){***}.
so here is what my logoutBtnClicked() looks like:
//clicked logout
#IBAction func logout(sender: AnyObject) {
PFUser.logOutInBackgroundWithBlock { (error: NSError?) -> Void in
if error == nil {
NSUserDefaults.standardUserDefaults().removeObjectForKey("username")
NSUserDefaults.standardUserDefaults().synchronize()
let signin = self.storyboard?.instantiateViewControllerWithIdentifier("signinViewController") as! SigninViewController
let appDelegate: AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
appDelegate.window?.rootViewController = signin
}
}
}
2016-08-18 21:18:54.801 helloworld[2439:115160] -[helloworld.HomeViewController Logout:]: unrecognized selector sent to instance 0x78e38840
2016-08-18 21:18:54.829 helloworld[2439:115160] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[helloworld.HomeViewController Logout:]: unrecognized selector sent to instance 0x78e38840'
* First throw call stack:
(
0 CoreFoundation 0x018d1494 exceptionPreprocess + 180
1 libobjc.A.dylib 0x035e5e02 objc_exception_throw + 50
2 CoreFoundation 0x018db253 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0181089d ___forwarding_ + 1037
4 CoreFoundation 0x0181046e _CF_forwarding_prep_0 + 14
5 libobjc.A.dylib 0x035fa0b5 -[NSObject performSelector:withObject:withObject:] + 84
6 UIKit 0x020c1e38 -[UIApplication sendAction:to:from:forEvent:] + 118
7 UIKit 0x025519da -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 179
8 libobjc.A.dylib 0x035fa0b5 -[NSObject performSelector:withObject:withObject:] + 84
9 UIKit 0x020c1e38 -[UIApplication sendAction:to:from:forEvent:] + 118
10 UIKit 0x020c1db7 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64
11 UIKit 0x02265f3b -[UIControl sendAction:to:forEvent:] + 79
12 UIKit 0x022662d4 -[UIControl _sendActionsForEvents:withEvent:] + 433
13 UIKit 0x02266483 -[UIControl _sendActionsForEvents:withEvent:] + 864
14 UIKit 0x022652c1 -[UIControl touchesEnded:withEvent:] + 714
15 UIKit 0x0214252e -[UIWindow _sendTouchesForEvent:] + 1095
16 UIKit 0x021435cc -[UIWindow sendEvent:] + 1159
17 UIKit 0x020e4be8 -[UIApplication sendEvent:] + 266
18 UIKit 0x020b9769 _UIApplicationHandleEventQueue + 7795
19 CoreFoundation 0x017e3e5f CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 15
20 CoreFoundation 0x017d9aeb __CFRunLoopDoSources0 + 523
21 CoreFoundation 0x017d8f08 __CFRunLoopRun + 1032
22 CoreFoundation 0x017d8846 CFRunLoopRunSpecific + 470
23 CoreFoundation 0x017d865b CFRunLoopRunInMode + 123
24 GraphicsServices 0x05f27664 GSEventRunModal + 192
25 GraphicsServices 0x05f274a1 GSEventRun + 104
26 UIKit 0x020bfeb9 UIApplicationMain + 160
27 helloworld 0x0007a4e1 main + 145
28 libdyld.dylib 0x043bba25 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
The problem is that in the interface builder for HomeViewController, for button action you have set Logout and inside the class of HomeViewController it is declare as logout, action and property are case sensitive, so either change one of them will solve your crash.

Invalid pairing of layout attributes when specifying constraints programmatically in code in swift VC

I am following the pattern used in the the example here :
https://github.com/lucasderraugh/AppleProg-Cocoa-Tutorials/blob/master/Lesson%2066/Lesson%2066/AppDelegate.swift
My VC (subclass of NSViewController) looks like this :
import Cocoa
class SecondViewController: NSViewController {
var leftView = ColorView()
var rightView = ColorView()
#IBOutlet weak var nameTextField: NSTextField!
override func viewDidLoad() {
super.viewDidLoad()
// Do view setup here.
}
override func viewDidAppear() {
leftView.translatesAutoresizingMaskIntoConstraints = false
rightView.translatesAutoresizingMaskIntoConstraints = false
let leftConstraints:[NSLayoutConstraint] = [
leftView.widthAnchor.constraintEqualToAnchor(self.view.topAnchor),
leftView.leftAnchor.constraintEqualToAnchor(self.view.leftAnchor),
leftView.widthAnchor.constraintEqualToConstant(100),
leftView.heightAnchor.constraintEqualToConstant(100)
]
self.view.addSubview(leftView)
NSLayoutConstraint.activateConstraints(leftConstraints)
}
override func prepareForSegue(segue: NSStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "SecondToFourthSegue" {
(segue.destinationController as! NSViewController).representedObject = nameTextField.stringValue
}
}
}
But I get the following error at runtime :
Invalid pairing of layout attributes
The full stack trace :
2016-04-26 00:54:06.402 Hyperterm[19046:1591173] An uncaught exception was raised
2016-04-26 00:54:06.403 Hyperterm[19046:1591173] *** +[NSLayoutConstraint constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:]: Invalid pairing of layout attributes
2016-04-26 00:54:06.403 Hyperterm[19046:1591173] (
0 CoreFoundation 0x00007fff89cf94f2 __exceptionPreprocess + 178
1 libobjc.A.dylib 0x00007fff8b89b73c objc_exception_throw + 48
2 CoreFoundation 0x00007fff89d604bd +[NSException raise:format:] + 205
3 Foundation 0x00007fff8d717f92 VerifyConstraintArguments + 356
4 Foundation 0x00007fff8d717c16 +[NSLayoutConstraint constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:] + 295
5 Foundation 0x00007fff8d71d410 -[NSLayoutAnchor constraintEqualToAnchor:multiplier:constant:] + 149
6 Foundation 0x00007fff8d71e87f -[NSLayoutDimension constraintEqualToAnchor:multiplier:constant:] + 39
7 Hyperterm 0x000000010001bee1 _TFC9Hyperterm20SecondViewController13viewDidAppearfT_T_ + 385
8 Hyperterm 0x000000010001c4b2 _TToFC9Hyperterm20SecondViewController13viewDidAppearfT_T_ + 34
9 libdispatch.dylib 0x0000000100607070 _dispatch_call_block_and_release + 12
10 libdispatch.dylib 0x00000001005f9cc5 _dispatch_client_callout + 8
11 libdispatch.dylib 0x00000001006116ae _dispatch_main_queue_callback_4CF + 2845
12 CoreFoundation 0x00007fff89cae9e9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
13 CoreFoundation 0x00007fff89c6d8dd __CFRunLoopRun + 1949
14 CoreFoundation 0x00007fff89c6ced8 CFRunLoopRunSpecific + 296
15 HIToolbox 0x00007fff949a7935 RunCurrentEventLoopInMode + 235
16 HIToolbox 0x00007fff949a776f ReceiveNextEventCommon + 432
17 HIToolbox 0x00007fff949a75af _BlockUntilNextEventMatchingListInModeWithFilter + 71
18 AppKit 0x00007fff878aeefa _DPSNextEvent + 1067
19 AppKit 0x00007fff878ae32a -[NSApplication _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 454
20 AppKit 0x00007fff878a2e84 -[NSApplication run] + 682
21 AppKit 0x00007fff8786c46c NSApplicationMain + 1176
22 Hyperterm 0x000000010001b724 main + 84
23 libdyld.dylib 0x00007fff8fc285ad start + 1
24 ??? 0x0000000000000003 0x0 + 3
)
2016-04-26 00:54:06.405 Hyperterm[19046:1591173] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[NSLayoutConstraint constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:]: Invalid pairing of layout attributes'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff89cf94f2 __exceptionPreprocess + 178
1 libobjc.A.dylib 0x00007fff8b89b73c objc_exception_throw + 48
2 CoreFoundation 0x00007fff89d604bd +[NSException raise:format:] + 205
3 Foundation 0x00007fff8d717f92 VerifyConstraintArguments + 356
4 Foundation 0x00007fff8d717c16 +[NSLayoutConstraint constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:] + 295
5 Foundation 0x00007fff8d71d410 -[NSLayoutAnchor constraintEqualToAnchor:multiplier:constant:] + 149
6 Foundation 0x00007fff8d71e87f -[NSLayoutDimension constraintEqualToAnchor:multiplier:constant:] + 39
7 Hyperterm 0x000000010001bee1 _TFC9Hyperterm20SecondViewController13viewDidAppearfT_T_ + 385
8 Hyperterm 0x000000010001c4b2 _TToFC9Hyperterm20SecondViewController13viewDidAppearfT_T_ + 34
9 libdispatch.dylib 0x0000000100607070 _dispatch_call_block_and_release + 12
10 libdispatch.dylib 0x00000001005f9cc5 _dispatch_client_callout + 8
11 libdispatch.dylib 0x00000001006116ae _dispatch_main_queue_callback_4CF + 2845
12 CoreFoundation 0x00007fff89cae9e9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
13 CoreFoundation 0x00007fff89c6d8dd __CFRunLoopRun + 1949
14 CoreFoundation 0x00007fff89c6ced8 CFRunLoopRunSpecific + 296
15 HIToolbox 0x00007fff949a7935 RunCurrentEventLoopInMode + 235
16 HIToolbox 0x00007fff949a776f ReceiveNextEventCommon + 432
17 HIToolbox 0x00007fff949a75af _BlockUntilNextEventMatchingListInModeWithFilter + 71
18 AppKit 0x00007fff878aeefa _DPSNextEvent + 1067
19 AppKit 0x00007fff878ae32a -[NSApplication _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 454
20 AppKit 0x00007fff878a2e84 -[NSApplication run] + 682
21 AppKit 0x00007fff8786c46c NSApplicationMain + 1176
22 Hyperterm 0x000000010001b724 main + 84
23 libdyld.dylib 0x00007fff8fc285ad start + 1
24 ??? 0x0000000000000003 0x0 + 3
)
libc++abi.dylib: terminating with uncaught exception of type NSException
leftView.widthAnchor should not equal to self.view.topAnchor You might not pay attention to it

Adding audio player to a node in SceneKit

I have some problems with adding an audio player to a node. For some reason, I get an exception and my application stops. Here is how my code looks like
let node = scene.rootNode.childNodeWithName("box", recursively: true)!
let source = SCNAudioSource(fileNamed: "test.mp3")
source.loops = true
source.volume = 2
source.positional = true
source.shouldStream = true
source.load()
let player = SCNAudioPlayer(source: source)
node.addAudioPlayer(player)
Can anybody help me find out what is the problem?
Edit: Exception:
2015-06-12 10:44:29.202 asd[10480:2157476] 10:44:29.202 ERROR: AVAudioNodeImpl.h:39: AVAE_CheckNodeHasEngine: required condition is false: _engine != nil
2015-06-12 10:44:29.208 asd[10480:2157476] * Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'required condition is false: _engine != nil'
* First throw call stack:
(
0 CoreFoundation 0x000000010ca18885 exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010e9afdf1 objc_exception_throw + 48
2 CoreFoundation 0x000000010ca186ea +[NSException raise:format:arguments:] + 106
3 libAVFAudio.dylib 0x0000000115549efe libAVFAudio.dylib + 98046
4 libAVFAudio.dylib 0x000000011558b4fd libAVFAudio.dylib + 365821
5 libAVFAudio.dylib 0x000000011558aaa5 libAVFAudio.dylib + 363173
6 SceneKit 0x000000010d3695eb C3DTransactionFlush + 1967
7 SceneKit 0x000000010d3699e9 C3DTransactionCommit + 218
8 SceneKit 0x000000010d2f7f6e -[SCNRenderer setPointOfView:] + 4677
9 SceneKit 0x000000010d2f8c05 -[SCNRenderer setScene:completionHandler:] + 213
10 SceneKit 0x000000010d354920 -[SCNView setScene:] + 319
11 asd 0x000000010c8338b2 _TFC3asd18GameViewController11viewDidLoadfS0_FT_T_ + 2866
12 asd 0x000000010c833ba2 _TToFC3asd18GameViewController11viewDidLoadfS0_FT_T_ + 34
13 UIKit 0x000000010d7bbd65 -[UIViewController loadViewIfRequired] + 860
14 UIKit 0x000000010d7bc0b4 -[UIViewController view] + 27
15 UIKit 0x000000010d69f3d4 -[UIWindow addRootViewControllerViewIfPossible] + 61
16 UIKit 0x000000010d69fad1 -[UIWindow _setHidden:forced:] + 302
17 UIKit 0x000000011c867717 UIKit + 247575
18 UIKit 0x000000010d6b0ff8 -[UIWindow makeKeyAndVisible] + 43
19 UIKit 0x000000010d63302b -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3545
20 UIKit 0x000000010d638ef0 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1755
21 UIKit 0x000000010d63673f -[UIApplication workspaceDidEndTransaction:] + 188
22 FrontBoardServices 0x0000000116052d7b FrontBoardServices + 163195
23 FrontBoardServices 0x0000000116053118 FrontBoardServices + 164120
24 CoreFoundation 0x000000010c9430f1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17
25 CoreFoundation 0x000000010c938eac __CFRunLoopDoSources0 + 556
26 CoreFoundation 0x000000010c938363 __CFRunLoopRun + 867
27 CoreFoundation 0x000000010c937d78 CFRunLoopRunSpecific + 488
28 UIKit 0x000000010d636091 -[UIApplication _run] + 402
29 UIKit 0x000000010d63a79b UIApplicationMain + 171
30 asd 0x000000010c83624d main + 109
31 libdyld.dylib 0x000000010f3a0a05 libdyld.dylib + 10757
32 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Try using SCNAction. Or making sure the audio file name is correct.
let source = SCNAudioSource(fileNamed: "SoundFile.mp3")
let action = SCNAction.playAudio(source!, waitForCompletion: true)
node.runAction(action)

UISearchBar strange issue

I have this log error when I tap in a uisearchbar (ios 7)
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: ' -[NSBigMutableString replaceCharactersInRange:withString:]: nil argument'
*** First throw call stack:
(
0 CoreFoundation 0x02c905e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x02a138b6 objc_exception_throw + 44
2 CoreFoundation 0x02c903bb +[NSException raise:format:] + 139
3 Foundation 0x0243863e -[NSBigMutableString replaceCharactersInRange:withString:] + 117
4 Foundation 0x02438595 -[NSConcreteMutableAttributedString replaceCharactersInRange:withAttributedString:] + 384
5 UIFoundation 0x077b49f4 __71-[NSConcreteTextStorage replaceCharactersInRange:withAttributedString:]_block_invoke + 68
6 UIFoundation 0x077b492f -[NSConcreteTextStorage replaceCharactersInRange:withAttributedString:] + 121
7 Foundation 0x02462d46 -[NSMutableAttributedString setAttributedString:] + 90
8 UIKit 0x016794e2 __65-[UIFieldEditor setAttributedText:andSetCaretSelectionAfterText:]_block_invoke + 53
9 UIFoundation 0x077b2491 -[NSTextStorage coordinateEditing:] + 48
10 UIKit 0x01679375 -[UIFieldEditor setAttributedText:andSetCaretSelectionAfterText:] + 151
11 UIKit 0x0167969b -[UIFieldEditor setAttributedText:] + 48
12 UIKit 0x01c5e3f5 -[UITextField willAttachFieldEditor:] + 340
13 UIKit 0x016784d5 -[UIFieldEditor becomeFieldEditorForView:] + 927
14 UIKit 0x01c55643 -[UITextField _becomeFirstResponder] + 160
15 UIKit 0x0184441a -[UISearchBarTextField _becomeFirstResponder] + 98
16 UIKit 0x01c554a1 -[UITextField __resumeBecomeFirstResponder] + 53
17 UIKit 0x0184466e __45-[UISearchBarTextField _becomeFirstResponder]_block_invoke + 259
18 UIKit 0x01844563 -[UISearchBarTextField _becomeFirstResponder] + 427
19 UIKit 0x016d2585 -[UIResponder becomeFirstResponder] + 400
20 UIKit 0x015d5d0b -[UIView(Hierarchy) becomeFirstResponder] + 114
21 UIKit 0x01c550e3 -[UITextField becomeFirstResponder] + 51
22 UIKit 0x018415b0 -[UISearchBar(UISearchBarStatic) becomeFirstResponder] + 42
23 UIKit 0x0183f9ef -[UISearchBar tappedSearchBar:] + 57
24 UIKit 0x018f0f8c _UIGestureRecognizerSendActions + 230
25 UIKit 0x018efc00 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 383
26 UIKit 0x018f166d -[UIGestureRecognizer _delayedUpdateGesture] + 60
27 UIKit 0x018f4bcd ___UIGestureRecognizerUpdate_block_invoke + 57
28 UIKit 0x018f4b4e _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 317
29 UIKit 0x018eb248 _UIGestureRecognizerUpdate + 199
30 UIKit 0x015b7d4a -[UIWindow _sendGesturesForEvent:] + 1291
31 UIKit 0x015b8c6a -[UIWindow sendEvent:] + 1030
32 UIKit 0x0158ca36 -[UIApplication sendEvent:] + 242
33 UIKit 0x01576d9f _UIApplicationHandleEventQueue + 11421
34 CoreFoundation 0x02c198af __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
35 CoreFoundation 0x02c1923b __CFRunLoopDoSources0 + 235
36 CoreFoundation 0x02c3630e __CFRunLoopRun + 910
37 CoreFoundation 0x02c35b33 CFRunLoopRunSpecific + 467
38 CoreFoundation 0x02c3594b CFRunLoopRunInMode + 123
39 GraphicsServices 0x0302d9d7 GSEventRunModal + 192
40 GraphicsServices 0x0302d7fe GSEventRun + 104
41 UIKit 0x0157994b UIApplicationMain + 1225
42 Mobile4Job 0x00002b5d main + 141
43 libdyld.dylib 0x03451725 start + 0
)
libc++abi.dylib: terminating with uncaught exception of type NSException
I never see something like that and I can't fix it.
From the stack trace a assume that you want to rebuild the text entered in the search bar, and you try to replace a string in a range with other string, and it seems that your other string is nil. Please check the the string that you are using, one of them is nil
I found the problem, I have an UITextfield implementation:
#implementation UITextField (clearCustomButton)
- (id)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if (self) {
}
return self;
}
- (void)awakeFromNib{
self.clearButtonMode = UITextFieldViewModeWhileEditing;
}
- (CGRect)clearButtonRectForBounds:(CGRect)bounds{
return CGRectMake(bounds.size.width - 20, (bounds.size.height - 14)/2, 14, 14);
}
#end
if I delete :
- (id)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if (self) {
}
return self;
}
it works. By the way, thanks to #danypata