Bool method to check user input - nsexception

Hi everybody i am trying to make a boolean method that will return value depending upon the user input for the field when submit button is clicked.
- (BOOL)checkuser:(NSString*)input
{
bool result = NO;
if ([input isEqualToString:#"test"])
{
result = YES;
}
else
{
result = NO;
}
return result;
}
And i am refrencing this method from my program as
else if ([Username checkuser] == YES)
{ // do something
}
with following warning
'NSString' may not respond to '-checkuser'
and i am not getting why my program crashing at this point with following error.
2011-03-22 22:57:25.942 Assignment 2[824:207] -[NSCFString checkuser]: unrecognized selector sent to instance 0x4b7c050
2011-03-22 22:57:25.944 Assignment 2[824:207] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString checkuser]: unrecognized selector sent to instance 0x4b7c050'
* Call stack at first throw:
(
0 CoreFoundation 0x00db8be9 exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f0d5c2 objc_exception_throw + 47
2 CoreFoundation 0x00dba6fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x00d2a366 __forwarding + 966
4 CoreFoundation 0x00d29f22 _CF_forwarding_prep_0 + 50
5 Assignment 2 0x00002958 -[Assignment_2ViewController SubmitbuttonPressed:] + 727
6 UIKit 0x002c1a6e -[UIApplication sendAction:to:from:forEvent:] + 119
7 UIKit 0x003501b5 -[UIControl sendAction:to:forEvent:] + 67
8 UIKit 0x00352647 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
9 UIKit 0x003511f4 -[UIControl touchesEnded:withEvent:] + 458
10 UIKit 0x002e60d1 -[UIWindow _sendTouchesForEvent:] + 567
11 UIKit 0x002c737a -[UIApplication sendEvent:] + 447
12 UIKit 0x002cc732 _UIApplicationHandleEvent + 7576
13 GraphicsServices 0x016eea36 PurpleEventCallback + 1550
14 CoreFoundation 0x00d9a064 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION + 52
15 CoreFoundation 0x00cfa6f7 __CFRunLoopDoSource1 + 215
16 CoreFoundation 0x00cf7983 __CFRunLoopRun + 979
17 CoreFoundation 0x00cf7240 CFRunLoopRunSpecific + 208
18 CoreFoundation 0x00cf7161 CFRunLoopRunInMode + 97
19 GraphicsServices 0x016ed268 GSEventRunModal + 217
20 GraphicsServices 0x016ed32d GSEventRun + 115
21 UIKit 0x002d042e UIApplicationMain + 1160
22 Assignment 2 0x00001c04 main + 102
23 Assignment 2 0x00001b95 start + 53
)
terminate called after throwing an instance of 'NSException'
Program received signal: “SIGABRT”.
(gdb)

You're over-complicating a very simple problem:
- (BOOL) checkuser:(NSString*)input {
return [input isEqualToString:#"test"];
}
and then to call it:
if ([Username checkUser:#"DONT FORGET YOUR PARAM HERE"]) {
// Do something...
}
In your example, you're not passing any parameter to your method... That's a misstake hence your error.
Also, if you create a method returning a 'BOOL', make sure you're returning a 'BOOL' and not a 'bool'. You have to always keep in mind that the underlying types can be different, even if a bool can be evaluated to a BOOL.

else if ([Username checkuser] == YES)
checkuser is supposed to receive a NSString*, which you are not sending though and is the reason for error messages. So, it should be -
Assuming someNSString is initialized and is of type NSString*.
else if( ([Username checkuser:someNSString] ) == YES )
// ^^^^^^^^^^^^ Needs to be passed as the method prototype mentions so.
{
// ....
}
NSString* someNSString = #"Forgot to pass this" ;
else if( ([Username checkuser:someNSString] ) == YES )
// ^^^^^^^^^^^^ Needs to be passed as the method prototype mentions so.
{
// ....
}

Related

SwiftUI Drag & Drop - NSInternalInconsistencyException: Could not get the cell at indexPath

I have implemented drag & drop between two lists in SwiftUI. Regular drag and drops work fine when dropping it in between list items, but when I do some more advanced drag like dragging it onto the cell itself, my app crashes.
This crash happens even before I drop it (so while I am still dragging it, without releasing drop)
Has anyone occurred this crash ? Is this a SwiftUI bug or am I doing something wrong ?
I have tried removing my code blocks inside dropDestinations and yet crash still exists, so what could I be doing wrong ?
Here is the gif of the crash (crash occurs right after I drag it onto the second cell, without dropping/releasing it):
Code inside dropDestination does not even get called.
SwiftUI Code
var body2: some View {
HStack {
VStack {
Text("title-pending")
List {
ForEach(viewModel.pendingOrders) { order in
RestaurantOrderCardView(order: order) {
.background(cardBackground)
.draggable(order)
}
.listRowSeparator(.hidden)
.listRowBackground(Color.clear)
.padding(.top)
}
.listStyle(.plain)
.background(listBackground)
}
VStack {
Text("title-in-preparation")
List {
ForEach(viewModel.inPreparationOrders) { item in
RestaurantOrderCardView(order: item)
.background(cardBackground)
}
.dropDestination(for: RestaurantOrder.self) { items, offset in
guard let firstItem = items.first else { return }
withAnimation {
viewModel.dropItem(firstItem, offset: offset)
}
}
.listRowSeparator(.hidden)
.listRowBackground(Color.clear)
.padding(.top)
}
.listStyle(.plain)
.background {
if !viewModel.inPreparationOrders.isEmpty {
listBackground
}
}
.overlay {
if viewModel.inPreparationOrders.isEmpty {
RoundedRectangle(cornerRadius: 8)
.foregroundColor(!inDropArea ? .grayBackgroundColor : .grayBackgroundColor.opacity(0.25))
.ignoresSafeArea()
.dropDestination(for: RestaurantOrder.self) { items, location in
guard let firstItem = items.first else { return false }
withAnimation {
viewModel.dropItem(firstItem, offset: 0)
}
return true
} isTargeted: { inDropArea in
withAnimation {
self.inDropArea = inDropArea
}
}
}
}
}
}
}
Crash Log
2023-01-06 11:25:05.995303+0100 SimplifyStayAdmin[78761:2158775] *** Assertion failure in -[_UICollectionViewDragAndDropController _beginDragAndDropInsertingItemAtIndexPath:], _UICollectionViewDragAndDropController.m:620
2023-01-06 11:25:06.074407+0100 SimplifyStayAdmin[78761:2158775] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not get the cell at indexPath <NSIndexPath: 0x8846e25efd6dfbf1> {length = 2, path = 0 - 0} to start the reording portion of the Drag-and-drop'
*** First throw call stack:
(
0 CoreFoundation 0x000000018040e7c8 __exceptionPreprocess + 172
1 libobjc.A.dylib 0x0000000180051144 objc_exception_throw + 56
2 Foundation 0x0000000180b13b98 _userInfoForFileAndLine + 0
3 UIKitCore 0x0000000109a546ec -[_UICollectionViewDragAndDropController _beginDragAndDropInsertingItemAtIndexPath:] + 540
4 UIKitCore 0x0000000109a53064 -[_UICollectionViewDragAndDropController beginReorderingForItemAtIndexPath:cell:] + 204
5 UIKitCore 0x0000000109a1bad0 -[UICollectionView _beginInteractiveMovementForItemAtIndexPath:] + 196
6 UIKit 0x000000011803040c -[UICollectionViewAccessibility beginInteractiveMovementForItemAtIndexPath:] + 80
7 UIKitCore 0x0000000109a5c55c -[_UICollectionViewDragDestinationController _reorderingDisplayLinkDidTick] + 912
8 QuartzCore 0x0000000187dd04f8 _ZN2CA7Display11DisplayLink14dispatch_itemsEyyy + 808
9 QuartzCore 0x0000000187ec89a8 _ZL22display_timer_callbackP12__CFMachPortPvlS1_ + 336
10 CoreFoundation 0x000000018033ee94 __CFMachPortPerform + 172
11 CoreFoundation 0x000000018037387c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 56
12 CoreFoundation 0x0000000180372e9c __CFRunLoopDoSource1 + 496
13 CoreFoundation 0x000000018036d43c __CFRunLoopRun + 2176
14 CoreFoundation 0x000000018036c7a4 CFRunLoopRunSpecific + 584
15 GraphicsServices 0x0000000188ff7c98 GSEventRunModal + 160
16 UIKitCore 0x000000010a1f237c -[UIApplication _run] + 868
17 UIKitCore 0x000000010a1f6374 UIApplicationMain + 124
18 SwiftUI 0x000000010e6150d4 OUTLINED_FUNCTION_51 + 496
19 SwiftUI 0x000000010e614f7c OUTLINED_FUNCTION_51 + 152
20 SwiftUI 0x000000010dd7ab60 OUTLINED_FUNCTION_10 + 88
21 SimplifyStayAdmin 0x000000010044d0c4 $s17SimplifyStayAdmin0abC3AppV5$mainyyFZ + 40
22 SimplifyStayAdmin 0x000000010044d378 main + 12
23 dyld 0x00000001080c1fa0 start_sim + 20
24 ??? 0x00000001081c9e50 0x0 + 4431060560
25 ??? 0x0869800000000000 0x0 + 606156362346397696
)
libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not get the cell at indexPath <NSIndexPath: 0x8846e25efd6dfbf1> {length = 2, path = 0 - 0} to start the reording portion of the Drag-and-drop'
terminating with uncaught exception of type NSException
CoreSimulator 857.14 - Device: iPad (10th generation) (D79A0AD8-4970-4F84-A5F9-078DAFB697A3) - Runtime: iOS 16.2 (20C52) - DeviceType: iPad (10th generation)

How to fix the crash in CFNotificationCenterAddObserver for NSWorkspaceDidActivateApplicationNotification?

Not very much accustom to Objective C, hence trying to observe NSWorkspaceDidActivateApplicationNotification event in C++ code with CFNotificationCenterAddObserver() method.
#include<CoreFoundation/CFNotificationCenter.h>
#include<iostream>
#include<QGuiApplication>
void Callback (CFNotificationCenterRef center, void* observer, CFNotificationName name,
const void* object,
CFDictionaryRef userInfo)
{
std::cout << "Hello World\n";
//NSLog(#"New application: %#", [[name userInfo] objectForKey:NSWorkspaceApplicationKey]);
}
int main (int argc, char** argv)
{
QGuiApplication application(argc, argv);
std::cout << "Add observer\n";
CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(), nullptr, Callback,
CFStringRef("NSWorkspaceDidActivateApplicationNotification"), nullptr,
CFNotificationSuspensionBehaviorDeliverImmediately);
std::cout << "Added ...\n";
return application.exec();
}
However it results in below crash. If I try to run in debug mode, then it sometimes shows the below crash or sometimes get stuck in that function itself.
Add observer
2021-12-03 21:44:24.527086+0530 Test[17288:982994] -[__NSTaggedDate length]: unrecognized selector sent to instance 0x100007c65
2021-12-03 21:44:24.527916+0530 Test[17288:982994] [General] An uncaught exception was raised
2021-12-03 21:44:24.527943+0530 Test[17288:982994] [General] -[__NSTaggedDate length]: unrecognized selector sent to instance 0x100007c65
2021-12-03 21:44:24.528044+0530 Test[17288:982994] [General] (
0 CoreFoundation 0x00007fff35570035 __exceptionPreprocess + 256
1 libobjc.A.dylib 0x00007fff5fc80a17 objc_exception_throw + 48
2 CoreFoundation 0x00007fff355e9fce -[NSObject(NSObject) __retain_OA] + 0
3 CoreFoundation 0x00007fff35511e9f ___forwarding___ + 1485
4 CoreFoundation 0x00007fff35511848 _CF_forwarding_prep_0 + 120
5 CoreFoundation 0x00007fff355aca4c __CFXNotificationRegisterObserver + 588
6 CoreFoundation 0x00007fff3548a037 CFNotificationCenterAddObserver + 204
7 Test 0x00000001000066a1 main + 129
8 libdyld.dylib 0x00007fff614503d5 start + 1
)
2021-12-03 21:44:24.528241+0530 Test[17288:982994] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSTaggedDate length]: unrecognized selector sent to instance 0x100007c65'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff35570035 __exceptionPreprocess + 256
1 libobjc.A.dylib 0x00007fff5fc80a17 objc_exception_throw + 48
2 CoreFoundation 0x00007fff355e9fce -[NSObject(NSObject) __retain_OA] + 0
3 CoreFoundation 0x00007fff35511e9f ___forwarding___ + 1485
4 CoreFoundation 0x00007fff35511848 _CF_forwarding_prep_0 + 120
5 CoreFoundation 0x00007fff355aca4c __CFXNotificationRegisterObserver + 588
6 CoreFoundation 0x00007fff3548a037 CFNotificationCenterAddObserver + 204
7 Test 0x00000001000066a1 main + 129
8 libdyld.dylib 0x00007fff614503d5 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
How to fix this?
Use CFSTR macro to create a CFStringRef from a constant C string like so:
CFSTR("NSWorkspaceDidActivateApplicationNotification")
NSWorkspaceDidActivateApplicationNotification docs says that you have to use NSWorkspace.notificationCenter to receive it, CFNotificationCenterGetDistributedCenter won't work.

SwiftUI View adding #Environment(\.presentationMode) crashes .sheet() presentation

I have view that uses .sheet() to present modally some another ChildView
I want to dismiss ParentView when this sheet is dismissed. So there is onDismiss callback.
However when I add
#Environment(\.presentationMode) var presentationMode
then presenting sheet it crashes with such bug
libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present
modally a view controller
<TtGC7SwiftUI29PresentationHostingControllerVS_7AnyView:
0x7ffc07175c60> that is already being presented by
<TtGC7SwiftUI19UIHostingControllerGVS_15ModifiedContentVS_7AnyViewVS_12RootModifier_:
0x7ffc04438c00>.' terminating with uncaught exception of type
NSException CoreSimulator 757.5 - Device: iPhone 12 Pro
(DEE900D2-F542-496C-9000-14498B9AA407) - Runtime: iOS 14.5 (18E182) -
DeviceType: iPhone 12 Pro
Without using this environment property everything works ok.
It seems that sheet tries to present itself multiple times then this property is available.
But on other screens (views) everything works ok.
*** First throw call stack:
(
0 CoreFoundation 0x0000000113b4ffba __exceptionPreprocess + 242
1 libobjc.A.dylib 0x00000001136cdff5 objc_exception_throw + 48
2 UIKitCore 0x0000000121df4f32 -[UIViewController _presentViewController:withAnimationController:completion:] + 6016
3 UIKitCore 0x0000000121df593c __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 98
4 UIKitCore 0x0000000121e1049c -[_UIViewControllerTransitionCoordinator _applyBlocks:releaseBlocks:] + 294
5 UIKitCore 0x0000000121e0c70e -[_UIViewControllerTransitionContext _runAlongsideCompletions] + 126
6 UIKitCore 0x0000000121e0c482 -[_UIViewControllerTransitionContext completeTransition:] + 106
7 UIKitCore 0x0000000122a2f3cc -[UITransitionView notifyDidCompleteTransition:] + 247
8 UIKitCore 0x0000000122a2f069 -[UITransitionView _didCompleteTransition:] + 1422
9 UIKitCore 0x0000000122a68e7a -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 779
10 UIKitCore 0x0000000122a39831 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 231
11 UIKitCore 0x0000000122a39dd6 -[UIViewAnimationState animationDidStop:finished:] + 263
12 UIKitCore 0x0000000122a39f57 -[UIViewAnimationState animationDidStop:finished:] + 648
13 QuartzCore 0x00000001122a8dc0 _ZN2CA5Layer23run_animation_callbacksEPv + 308
14 libdispatch.dylib 0x000000011ab8b74e _dispatch_client_callout + 8
15 libdispatch.dylib 0x000000011ab99b3f _dispatch_main_queue_callback_4CF + 1152
16 CoreFoundation 0x0000000113abd8f8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
17 CoreFoundation 0x0000000113ab8169 __CFRunLoopRun + 2781
18 CoreFoundation 0x0000000113ab71a7 CFRunLoopRunSpecific + 567
19 GraphicsServices 0x0000000121151d85 GSEventRunModal + 139
20 UIKitCore 0x000000012251d4df -[UIApplication _run] + 912
21 UIKitCore 0x000000012252239c UIApplicationMain + 101
22 SwiftUI 0x0000000115b15c36 $s7SwiftUI17KitRendererCommon33_ACC2C5639A7D76F611E170E831FCA491LLys5NeverOyXlXpFAESpySpys4Int8VGSgGXEfU_ + 119
23 SwiftUI 0x0000000115b15bbd $s7SwiftUI6runAppys5NeverOxAA0D0RzlF + 143
24 SwiftUI 0x0000000115652384 $s7SwiftUI3AppPAAE4mainyyFZ + 61
25 Pro 0x0000000104d6bf40 $s3Pro0A3AppV5$mainyyFZ + 48
26 Pro 0x0000000104d6bfd4 main + 20
27 libdyld.dylib 0x000000011ac19bbd start + 1
Sample code looks like this
struct ParentView: View {
#Environment(\.presentationMode) var presentationMode
var body: some View {
mainButton
.sheet(
item: $viewModel.item,
onDismiss: {
},
content: { summary in
ChildView()
}
)
}
}
Ok I found solution. What was causing the problem was that when there is Environment(.presentationMode) there is some refreshing done on this view
.sheet(item:) relies on Identifiable type that requires id.
It has this id but if it used optional identifier with like
var id: String { myId ?? UUID().uuidString }
When there wasn't this Environment this underlying model id doesn't change but with Environment property underlying item model has recalculated id and it was causing problem by trying to present this view double times.

Crash reported generated by Compiler in Swift 5 xcode 11

My app has been rejected from Apple quite a long time now.
They say that I get crash on dashboard but although it works fine on simulator and device
I implemented 2 approaches to get the crash report
Firebase Analytics
Symbolised the crash reported shared by Apple.
.init(coder:)
It says error generated by compiler
8 SSBS 0x10521c174 DashboardViewController.init(coder:) + 5308788 (<compiler-generated>:0)
9 SSBS 0x10521c238 #objc DashboardViewController.init(coder:) + 5308984 (<compiler-generated>:0)
In this case, what do I need to implement in my ViewController Class file
So the crash report generated fr
om that is :
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Triggered by Thread: 0
*Last Exception Backtrace:
0 CoreFoundation 0x1adc3b794 0x1adb11000 + 1222548
1 libobjc.A.dylib 0x1ad95dbcc 0x1ad958000 + 23500
2 CoreFoundation 0x1adb31b98 0x1adb11000 + 134040
3 UIKitCore 0x1b1652c74 0x1b12b4000 + 3796084
4 UIFoundation 0x1b123fe94 0x1b11d5000 + 437908
5 UIFoundation 0x1b12400b4 0x1b11d5000 + 438452
6 UIFoundation 0x1b11dccac 0x1b11d5000 + 31916
7 UIKitCore 0x1b1699dd0 0x1b12b4000 + 4087248
8 SSBS 0x10521c174 DashboardViewController.init(coder:) + 5308788 (<compiler-generated>:0)
9 SSBS 0x10521c238 #objc DashboardViewController.init(coder:) + 5308984 (<compiler-generated>:0)
10 UIKitCore 0x1b1973c40 0x1b12b4000 + 7076928
11 UIFoundation 0x1b123fe94 0x1b11d5000 + 437908
12 UIFoundation 0x1b11dccac 0x1b11d5000 + 31916
13 UIKitCore 0x1b1977bbc 0x1b12b4000 + 7093180
14 UIFoundation 0x1b123fe94 0x1b11d5000 + 437908
15 UIFoundation 0x1b12400b4 0x1b11d5000 + 438452
16 UIFoundation 0x1b11dccac 0x1b11d5000 + 31916
17 UIKitCore 0x1b1972cd8 0x1b12b4000 + 7072984
18 UIKitCore 0x1b1975858 0x1b12b4000 + 7084120
19 UIKitCore 0x1b1e4784c 0x1b12b4000 + 12138572
20 SSBS 0x1052b55a8 closure #1 in LoginViewController.RegisterUserOnServer() + 5936552 (LoginViewController.swift:707)
21 Alamofire 0x105e47454 0x105d54000 + 996436
22 Alamofire 0x105d7ac94 0x105d54000 + 158868
23 libdispatch.dylib 0x1ad9009a8 0x1ad8a6000 + 371112
24 libdispatch.dylib 0x1ad901524 0x1ad8a6000 + 374052
25 libdispatch.dylib 0x1ad8b35b4 0x1ad8a6000 + 54708
26 CoreFoundation 0x1adbb97fc 0x1adb11000 + 690172
27 CoreFoundation 0x1adbb46d0 0x1adb11000 + 669392
28 CoreFoundation 0x1adbb3ce8 0x1adb11000 + 666856
29 GraphicsServices 0x1b7cfe38c 0x1b7cfb000 + 13196
30 UIKitCore 0x1b1ce2444 0x1b12b4000 + 10675268
31 SSBS 0x1051ba4b4 main + 4908212 (AppDelegate.swift:21)
32 libdyld.dylib 0x1ada3b8f0 0x1ada3a000 + 6384
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x00000001ada30d88 0x1ada0b000 + 155016
1 libsystem_pthread.dylib 0x00000001ad9491e8 0x1ad947000 + 8680
2 libsystem_c.dylib 0x00000001ad89c9b0 0x1ad82a000 + 469424
3 libsystem_c.dylib 0x00000001ad89c940 0x1ad82a000 + 469312
4 libc++abi.dylib 0x00000001ada04cc0 0x1ad9f2000 + 76992
5 libc++abi.dylib 0x00000001ad9f6e10 0x1ad9f2000 + 19984
6 libobjc.A.dylib 0x00000001ad95de80 0x1ad958000 + 24192
7 SSBS 0x0000000105501948 FIRCLSTerminateHandler() + 8345928 (FIRCLSException.mm:338)
8 SSBS 0x00000001054abc90 CLSTerminateHandler+ 7994512 () + 348
9 libc++abi.dylib 0x00000001ada0414c 0x1ad9f2000 + 74060
10 libc++abi.dylib 0x00000001ada040e4 0x1ad9f2000 + 73956
11 libdispatch.dylib 0x00000001ad901538 0x1ad8a6000 + 374072
12 libdispatch.dylib 0x00000001ad8b35b4 0x1ad8a6000 + 54708
13 CoreFoundation 0x00000001adbb97fc 0x1adb11000 + 690172
14 CoreFoundation 0x00000001adbb46d0 0x1adb11000 + 669392
15 CoreFoundation 0x00000001adbb3ce8 0x1adb11000 + 666856
16 GraphicsServices 0x00000001b7cfe38c 0x1b7cfb000 + 13196
17 UIKitCore 0x00000001b1ce2444 0x1b12b4000 + 10675268
18 SSBS 0x00000001051ba4b4 main + 4908212 (AppDelegate.swift:21)
19 libdyld.dylib 0x00000001ada3b8f0 0x1ada3a000 + 6384*
code of DashboardViewController:
class DashboardViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
//navigationHeaderItem()
// Do any additional setup after loading the view.
if(self.isNewDashboard == nil || self.isNewDashboard == true){
self.newDashboardView.isHidden = false
}else{
self.newDashboardView.isHidden = true
}
let menuMangerObj = MenuDrawerManager()
let resultItem=menuMangerObj.getByItemDrawerItem("My Meetings") as NSArray
if(resultItem.count>0){
self.newDashboardView.isHidden = false
}else{
self.newDashboardView.isHidden = true
}
self.loginUserName.text=userdDefaultData.string(forKey: "loginUserName")
}
}
I initiate a view controller like:
let vcObj = self.storyboard?.instantiateViewController(withIdentifier: "DashboardController") as! DashboardViewController
vcObj.isNewDashboard = true
self.navigationController?.pushViewController(vcObj, animated: true)
Am I am missing anything here?

CCLabelBMFont fails on setString with update

I have Cocos2d app that fail randomly for some user when i try to display a CCLabelBMFont with animation. I'm not able to reproduce the issue on any of my test device. Since it seem to fail on line 845 I'm wondering if I'm runing out of mmemory. I'm using cocos2d v2.0.0.
for (TileBlockModel* tile in [matchInfo tiles]) {
if (tile.matchScore > 0 && tile.spriteObject != nil) {
NSString* str = [NSString stringWithFormat:#"%d",tile.matchScore];
CCLabelBMFont* label = [CCLabelBMFont labelWithString:str fntFile:#"8-WHITE NUMBERS.fnt"];
label.position = ((CCNode*)tile.spriteObject).position;
label.scale = label.scale * fontMultiplier;
label.zOrder = TILE_BLOCK_SCORE_Z_LEVEL;
[gameGrid addChild:label];
CCActionInterval* action = [CCSequence actions:
[CCMoveBy actionWithDuration:.4 position:ccp(0, ((CCNode*)tile.spriteObject).boundingBox.size.height)],
[CCCallBlockN actionWithBlock:^(CCNode* node){
[node removeFromParentAndCleanup:YES];
}],
nil];
[label runAction:[CCSpeedPointer actionWithAction:action speed_:globalGameSpeed]];
}
}
Crash log
0 vault2richesiphone 0x00078a02 -[CCLabelBMFont setString:updateLabel:] (CCLabelBMFont.m:845)
1 vault2richesiphone 0x00078d29 -[CCLabelBMFont setFntFile:] (CCLabelBMFont.m:921)
2 vault2richesiphone 0x00077f1d -[CCLabelBMFont updateLabel] (CCLabelBMFont.m:622)
3 vault2richesiphone 0x000b58b3 -[gameViewController displayMatchScore:] (gameViewController.m:1100)
4 vault2richesiphone 0x000b68ab -[gameViewController animateColumnDrop:andRow:andOffset:animationId:] (gameViewController.m:1226)
5 vault2richesiphone 0x0006755d -[CCRepeat stop] (CCActionInterval.m:307)
6 vault2richesiphone 0x0006c4bf -[CCProgressTo startWithTarget:] (CCActionProgressTimer.m:53)
7 vault2richesiphone 0x0008ca59 +[CCShaderCache sharedShaderCache] (CCShaderCache.m:41)
8 vault2richesiphone 0x000a070d -[CCDirectorIOS setProjection:] (CCDirectorIOS.m:217)
9 QuartzCore 0x3581c7a9 _ZN2CA7Display11DisplayLink8dispatchEyy + 161
10 QuartzCore 0x3581c701 _ZN2CA7Display16IOMFBDisplayLink8callbackEP21__IOMobileFramebufferyyyPv + 65
11 IOMobileFramebuffer 0x37a98fd7 IOMobileFramebufferVsyncNotifyFunc + 155
12 IOKit 0x3480f5ad IODispatchCalloutFromCFMessage + 193
13 CoreFoundation 0x33bf188b __CFMachPortPerform + 119
14 CoreFoundation 0x33bfc3e7 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 35
15 CoreFoundation 0x33bfc38b __CFRunLoopDoSource1 + 139
16 CoreFoundation 0x33bfb20f __CFRunLoopRun + 1383
17 CoreFoundation 0x33b6e23d CFRunLoopRunSpecific + 357
18 CoreFoundation 0x33b6e0c9 CFRunLoopRunInMode + 105
19 GraphicsServices 0x3774d33b GSEventRunModal + 75
20 UIKit 0x35a8a2b9 UIApplicationMain + 1121