The question is:
The following series of operations are performed on an empty stack, list the contents of the stack after these operations have completed?
Push 12
Push 2
Pop
Push 8
Push 23
Push 4
Pop
Pop
Push 63
My answer:
12, 8 , 63
It is because they pushed in 12, 2 and then poped so the last number that was in is the first one out which leaves 12. Then added 8,24 and 4 but then popped twice which leave 12, 8 and then pushed 63 which leaves the final answer the 12, 8 and 64
Can someone comfirm if I am right or wrong? If I am wrong why?
I would also like to ask, if we flush does they remove all the number or only check is all the numbers have been completed?
You are right. Here is the stack after every step:
12
12 2
12
12 8
12 8 23
12 8 23 4
12 8 23
12 8
12 8 63
After all operations you are left with 12 8 and 63.
Related
I have a problem with Xcode 11 running on Catalina (it had the same problem with Moave).
When I try to copy/paste a view or a ViewController from one storyboard to another Xcode crashes with this exception:
...
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Application Specific Information:
Sending paste: to IBStructureAreaDockView from <NSMenuItem: 0x7fe24030ddd0 Paste>
ProductBuildVersion: 11A1027
ASSERTION FAILURE in /Library/Caches/com.apple.xbs/Sources/IDEInterfaceBuilder/IDEInterfaceBuilder-15400/InterfaceBuilderKit/WidgetIntegration/View/IBViewIntegration.m:2451
Details: There should only be 1 parent of all the constraint items extracted from the pasteboard: {(
)}
Object: <IBUIView: 0x7fe23db1c600>
Method: -ibDidExtractObjects:fromPasteboard:intoDocument:context:
Thread: <NSThread: 0x7fe23ac17e80>{number = 1, name = main}
Hints:
0: Sending paste: to IBStructureAreaDockView from <NSMenuItem: 0x7fe24030ddd0 Paste>
Backtrace:
0 -[IDEAssertionHandler handleFailureInMethod:object:fileName:lineNumber:assertionSignature:messageFormat:arguments:] (in IDEKit)
1 _DVTAssertionHandler (in DVTFoundation)
2 _DVTAssertionFailureHandler (in DVTFoundation)
3 -[NSView(IBViewIntegration) ibDidExtractObjects:fromPasteboard:intoDocument:context:] (in IDEInterfaceBuilderKit)
4 -[IBUIView(IBUIViewIntegration) ibDidExtractObjects:fromPasteboard:intoDocument:context:] (in IDEInterfaceBuilderCocoaTouchIntegration)
5 -[IBDocument ibDidExtractObjects:fromPasteboard:context:] (in IDEInterfaceBuilderKit)
6 -[IBDocument insertObjectsFromPasteboard:ofType:asChildrenOfObject:atIndex:context:finishExtractingObjectsBlock:] (in IDEInterfaceBuilderKit)
7 -[IBDocument insertOrMoveChildrenFromPasteboard:ofType:asChildrenOfObject:atIndex:context:finishExtractingObjectsBlock:] (in IDEInterfaceBuilderKit)
8 -[IBDocument addOrMoveChildrenFromPasteboard:ofType:toObject:context:finishExtractingObjectsBlock:] (in IDEInterfaceBuilderKit)
9 -[IBStoryboardDocument addOrMoveChildrenFromPasteboard:ofType:toSceneGroup:context:] (in IDEInterfaceBuilderKit)
10 -[IBSceneDockViewController performDockPasteWithPasteboard:context:] (in IDEInterfaceBuilderKit)
11 -[IBSceneDockViewController dockViewPerformPaste:] (in IDEInterfaceBuilderKit)
12 -[IBStructureAreaDockView paste:] (in IDEInterfaceBuilderKit)
13 -[NSApplication(NSResponder) sendAction:to:from:] (in AppKit)
14 __37-[DVTApplication sendAction:to:from:]_block_invoke.86 (in DVTKit)
15 DVTInvokeWithFailureHint (in DVTFoundation)
16 -[DVTApplication sendAction:to:from:] (in DVTKit)
17 -[NSMenuItem _corePerformAction] (in AppKit)
18 -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] (in AppKit)
19 -[NSMenu performKeyEquivalent:] (in AppKit)
20 routeKeyEquivalent (in AppKit)
21 -[NSApplication(NSEvent) sendEvent:] (in AppKit)
22 -[IDEApplication sendEvent:] (in IDEKit)
23 -[NSApplication run] (in AppKit)
24 NSApplicationMain (in AppKit)
25 main (in Xcode)
26 start (in libdyld.dylib)
Performing #selector(paste:) from sender NSMenuItem 0x7fe24030ddd0
abort() called
Application Specific Signatures:
[parentsOfItemsInConstraints count] == 1
...
Is it happening to someone else? Is this something not supported by storyboard?
The issue for me was because i had the app running in the background. After closing the emulator i was able to copy/cut and paste (even in different storyboard files).
Xcode->Preferences-Locations
Click on the little arrow underneath "Derived Data" and delete that folder.
After I did this I could cut and paste between storyboards.
Same issue here. I think it's a bug with the new Xcode 11.
Found a quick workaround. Instead of copying and pasting view controllers which will cause Xcode to crash you can use cmd + D to duplicate the view controllers . But this will only be useful if in the same storyboard
Select View Controller, Edit > copy
On another storyboard, Edit > paste
i found a quick hack, go to your project navigator then right click on your .storyboard file and choose open as Source code.
you will get your storyboard in xml format, search and copy the class of the controller, and paste the same way you copied it in the other storyboard.
make sure to get the whole code of the view controller.
<!--Detail View Controller-->
<scene sceneID="n6l-mp-H1E"> .... </scene>
Its seems like kernel has issues while pasting the entire storyboard , But this only happens when the simulator apps is open . Close simulator app and try to paste it it works perfect
I tried clearing derived data and cleaning the project and the project folder and force restarted Xcode multiple times but all that didn't work.
Also I couldn't duplicated the views since I needed to copy in a different storyboard.
What eventually did the trick for me was to open an assistant editor and drag/drop whichever views I needed to copy.
CLOSE the SIMULATOR! That will work and allow the copy-paste of view controllers from different storyboards.
Two possible cases:
either you have to copy and paste from one project to another;
or within the same project, but different or same storyboard.
You can fix it by closing the emulator running in the background and then copy and paste or by copying and pasting from your storyboard (XML format).
I have found that instead of selecting the scene, selecting the view controller and perform a copy and paste to new storyboard worked.
Drag and drop worked instead of copy/paste for me. Happy coding!
I faces this issue lots of time, it seems like due to new version of Xcode.
Here is the solution that works for me.
Delete Derived Data and restart the XCode.
Clean & build the project.
Make sure XCode should not busy in following tasks:
Building Project
Indexing (wait until finish)
Running Project
Storyboard opening
Now you can try to copy one view controller from one storyboard to another it can be possible.
I've tried searching for this, but no luck, so hoping there are some guru's who may know the answer.
I'm seeing loads of reports in iTunes Connect of my app crashing with a particular stack trace, but the stack trace reveals nothing useful.
#0. Crashed: main
0 UIKit 0x1871100c0 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 324
1 UIKit 0x1871100bc __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 320
2 UIKit 0x1870630c8 _runAfterCACommitDeferredBlocks + 292
3 UIKit 0x187070a80 _cleanUpAfterCAFlushAndRunDeferredBlocks + 92
4 UIKit 0x186da25a4 _afterCACommitHandler + 96
5 CoreFoundation 0x181c0c728 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
6 CoreFoundation 0x181c0a4cc __CFRunLoopDoObservers + 372
7 CoreFoundation 0x181c0a8fc __CFRunLoopRun + 928
8 CoreFoundation 0x181b34c50 CFRunLoopRunSpecific + 384
9 GraphicsServices 0x18341c088 GSEventRunModal + 180
10 UIKit 0x186e1a088 UIApplicationMain + 204
11 MyApp 0x100082e6c main (main.m:19)
12 libdyld.dylib 0x1816d28b8 start + 4
No pattern to the reports, happens on iOS 9.1, 9.2, 9.3-10 and various iPhones and iPads and no clues to help reproduce it.
Has anyone experienced something like this before and have some insight/suspicion on what may cause it?
I have the exact same crash, and I've figured out the cause. A highly-reduced version of my code looks something like
[self dismissViewControllerAnimated:YES completion:nil];
// call a method that ends up doing
[appRootViewController dismissViewControllerAnimated:NO completion:nil];
self in the above snippet is a view controller that's been presented modally over the root. The view controller itself has also presented modally over current context some other controller. So what I'm doing is trying to dismiss that over-current-context controller with animation, then calling other code that ultimately dismisses any presented view controller from the root without animation.
Or to put it another way, the view controller providing the current context for an animated dismiss that I just kicked off gets removed from the view hierarchy while the previous animated dismissal is in progress.
When reproducing this in Xcode, it also logs the following to the console:
transitionViewForCurrentTransition is not set, presentation controller was dismissed during the presentation? (<_UIOverCurrentContextPresentationController: 0x7faf277d9c30>)
I know this is a generic question, but I hope that someone who had a similar experience may have an idea of what's probably happening.
I'm getting a crash that occurs only on iOS 9 in our iPad-only app. It says NSInternalInconsistencyException.
It occurs on both Portrait and Landscape modes, and on many iPad generations (iPad 2, iPad Pro, iPad 4, ...).
I don't have Auto Layout enabled anywhere in the project, yet it looks like an auto layout issue.
It's very hard to replicate, so I'm not able to debug it on Xcode, but I'm seeing reports on the crash analytics service "Crashlytics". Here's the stack trace from Crashlytics:
Auto layout internal error. Cannot find an outgoing row
head for incoming head <unknown var (bug!) with engine as delegate[...]
Thread : Fatal Exception: NSInternalInconsistencyException
0 CoreFoundation 0x23d4568b __exceptionPreprocess
1 libobjc.A.dylib 0x356c2e17 objc_exception_throw
2 CoreFoundation 0x23d455d1 -[NSException initWithCoder:]
3 Foundation 0x24a873b3 -[NSISEngine minimizeConstantInObjectiveRowWithHead:]
4 Foundation 0x24a86e4d -[NSISEngine optimize]
5 Foundation 0x24a82a53 -[NSISEngine withBehaviors:performModifications:]
6 UIKit 0x27e040bb -[UIView(Hierarchy) _postMovedFromSuperview:]
7 UIKit 0x280fb227 __UIViewWasRemovedFromSuperview
8 UIKit 0x27e02ddb -[UIView(Hierarchy) removeFromSuperview]
9 UIKit 0x282e5fa9 -[UIKeyboardPredictionView setPredictionViewState:animate:notify:]
10 UIKit 0x281e3787 -[UIKeyboardImpl updatePredictionView]
11 UIKit 0x27f155e3 -[UIKeyboardImpl finishLayoutChangeWithArguments:]
12 UIKit 0x27e31437 -[UIKeyboardImpl updateLayout]
13 UIKit 0x27e36077 -[UIKeyboardImpl setDelegate:force:]
14 UIKit 0x27e2f6e1 -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:]
15 UIKit 0x27e2f20d -[UIResponder(UIResponderInputViewAdditions) reloadInputViews]
16 UIKit 0x27e8d853 -[UIResponder becomeFirstResponder]
17 UIKit 0x27e8db6d -[UIView(Hierarchy) becomeFirstResponder]
18 UIKit 0x27f12289 -[UITextField becomeFirstResponder]
19 UIKit 0x27fbe69f -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) setFirstResponderIfNecessary]
20 UIKit 0x27fbdc75 -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) oneFingerTap:]
21 UIKit 0x28334e27 _UIGestureRecognizerSendTargetActions
22 UIKit 0x27fa2303 _UIGestureRecognizerSendActions
23 UIKit 0x27e3a7af -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:]
24 UIKit 0x28335f2f ___UIGestureRecognizerUpdate_block_invoke809
25 UIKit 0x27dfc287 _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks
26 UIKit 0x27df9e77 _UIGestureRecognizerUpdate
27 UIKit 0x27e386f9 -[UIWindow _sendGesturesForEvent:]
28 UIKit 0x27e37e43 -[UIWindow sendEvent:]
29 UIKit 0x27e097e5 -[UIApplication sendEvent:]
30 UIKit 0x27e07fdf _UIApplicationHandleEventQueue
31 CoreFoundation 0x23d08c3f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
32 CoreFoundation 0x23d0882d __CFRunLoopDoSources0
33 CoreFoundation 0x23d06b9b __CFRunLoopRun
34 CoreFoundation 0x23c5a249 CFRunLoopRunSpecific
35 CoreFoundation 0x23c5a035 CFRunLoopRunInMode
36 GraphicsServices 0x2cd24ad1 GSEventRunModal
37 UIKit 0x27e6f899 UIApplicationMain
38 Mr Appliance 0xcda7b main (main.m:16)
39 libdyld.dylib 0x35e0e873 start
The problem is that I don't know where in the code this is happening. The stack trace doesn't show where in the code the crash is occurring. It only says main.m line 16 which is return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));.
That line in main.m is where your program starts running, not where the error happens. The exception is thrown at #1 the top of the list after all the other items have happened. The problem lies somewhere in between.
After some view is removed from its superview there's an exception, and it does show NSISEngine errors indicating that perhaps AutoLayout is turned on for some XIB or Storyboard - or else iOS is using AutoLayout internally to handle the arrangement of the new layout.
This answer has a nearly identical stack trace & points to the issue being with using incorrect gesture methods to handle firstResponder changes and dismiss a keyboard. If you're doing something similar (dismissing some view, editing a UITableView?) maybe it's with the wrong method pointing to a delegate that doesn't exist?
https://stackoverflow.com/questions/33800918/uitextfield-becomefirstresponder-crashes-the-ios-app-randomly
The stacktrace indicates an issue regarding the onscreen keyboard. There is a layout change that ends up with a non exsistant delegate. Looks like your code triggers direct or indirect a layoutchange related to the keyboard.
Thing is, a keyboard on the screen is not grated even when your app does recive input.
As for the iPad Pro and the Smart Keyboard you may have a quicktype bar and that can be hidden too. Quite some apps have issues with external keyboards.
Try connecting a bluetooth keyboard to one of your test device. Connect it to xcode, set a breakpoint on exeptions and try your textfields. Guess you will find what you are looking for.
May be you might have misspelled any viewcontroller or xib name while initiating it or may be you have changed, name of the file, or moved it, in physical folder and forget to remove it from xcode.
I upgraded XCode 5 to 6 to test my projects out on the iPhone 6 and 6 Plus and was getting cryptic crashes on startup:
'*** -[__NSArrayM objectAtIndex:]: index 4 beyond bounds [0 .. 3]'
*** First throw call stack:
(
0 CoreFoundation 0x000000010569b3f5 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000104b20bb7 objc_exception_throw + 45
2 CoreFoundation 0x00000001055864d3 -[__NSArrayM objectAtIndex:] + 227
3 UIKit 0x00000001028164e1 _UIViewTopDownSubtreeTraversal + 193
4 UIKit 0x0000000102e43286 -[UIView(UIConstraintBasedLayout_EngineDelegate) _invalidateSystemLayoutSizeFittingSizeAtEngineDelegateLevel] + 128
5 Foundation 0x0000000103aa66df -[NSISEngine tryToAddConstraintWithMarker:expression:integralizationAdjustment:mutuallyExclusiveConstraints:] + 915
6 Foundation 0x0000000103c2f678 -[NSLayoutConstraint _addLoweredExpression:toEngine:integralizationAdjustment:lastLoweredConstantWasRounded:mutuallyExclusiveConstraints:] + 275
7 Foundation 0x0000000103a9ae3a -[NSLayoutConstraint _addToEngine:integralizationAdjustment:mutuallyExclusiveConstraints:] + 220
8 UIKit 0x0000000102e40495 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 474
9 Foundation 0x0000000103aa8a8e -[NSISEngine withBehaviors:performModifications:] + 155
10 UIKit 0x0000000102e4029b __57-[UIView(AdditionalLayoutSupport)
After a LOT of trial and error and trying various XIBs in various configurations, the issue occurred because I was mixing some XIBs with Auto Layout turned on, containing other UIViews (based on XIBs) with AutoLayout off.
Turning AutoLayout off for all of my XIBs solved the issue.
Faced the same issue. Found that the problem is in button whose layer was used as mask for another button's layer for some visual effect (CALayer's mask property). Removing mask button from view hierarchy fixed the problem. I just moved it to view controller scene in storyboard.
Looks like using layer as a mask caused problem in _UIViewTopDownSubtreeTraversal function used by autolayout. Maybe other layer manipulations for some view also can.
One solution I found is that you need to have at least 6 screens and then the app won't crash.
Still trying to get it to work with less screens.
Turned off Auto Layout on my only XIB (LaunchScreen.xib) but that didn't solve the problem.
I get crash at -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] without any trace refer to our app,could any one tell me what's the problem.
There are about 500 crashes with 99% on the ios7 System.
Thread : Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x397e1b26 objc_msgSend + 5
1 UIKit 0x31c358bb -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1078
2 UIKit 0x31ce8f7b -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 214
3 UIKit 0x31b98fb9 _applyBlockToCFArrayCopiedToStack + 316
4 UIKit 0x31b111f3 _afterCACommitHandler + 430
5 CoreFoundation 0x2f3711cd __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 20
6 CoreFoundation 0x2f36eb71 __CFRunLoopDoObservers + 284
7 CoreFoundation 0x2f36eeb3 __CFRunLoopRun + 730
8 CoreFoundation 0x2f2d9c27 CFRunLoopRunSpecific + 522
9 CoreFoundation 0x2f2d9a0b CFRunLoopRunInMode + 106
10 GraphicsServices 0x34000283 GSEventRunModal + 138
11 UIKit 0x31b7d049 UIApplicationMain + 1136
12 MyApp 0x0004e813 main (main.m:16)
#Umesh Kumar: YES
Finally, it turns out that its the navigation stacks confusion.
Here is the detail:
We all know two or more buttons action can be performed at the same time by default.(exclusiveTouch=NO)
Sometimes, when a button in you controller be taped which will cause the nav to push to next controller, but people may taped the back button on the left of the navbar which will simply pop the controller. This will cause the navigation stacks confusion. You will see the controller pushed in or poped back really strange.
When this happens, there will always be many strange crashes, include the crash I figured above.
Note that, According to my experience, This happens on IOS 7 only, and these crashes only happens on IOS 7 too.
So, we need to set button.exclusiveTouch = YES.But indeed, i realy do not know why this happens only on IOS 7.