1

Hey can anyone help me out that what type of exception is this i had earlier a code and link is as: Application run on simulator but not on device in iphone

can anybody here who can tell that what type of exception is in it? is there any memory leak?

here is the log below:

 2013-12-27 17:53:26.814 Skirr[1346:a0b] Application windows are expected to have a root view controller at the end of application launch
2013-12-27 17:53:27.995 Skirr[1346:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]'
*** First throw call stack:
(
    0   CoreFoundation                      0x032745e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x021b88b6 objc_exception_throw + 44
    2   CoreFoundation                      0x03228316 -[__NSPlaceholderArray initWithObjects:count:] + 390
    3   CoreFoundation                      0x0324bce9 +[NSArray arrayWithObject:] + 73
    4   Skirr                               0x000093bd -[SlideViewController viewDidLoad] + 1597
    5   UIKit                               0x00e2d318 -[UIViewController loadViewIfRequired] + 696
    6   UIKit                               0x00e2d5b4 -[UIViewController view] + 35
    7   UIKit                               0x00e473e2 -[UINavigationController _startCustomTransition:] + 778
    8   UIKit                               0x00e540c7 -[UINavigationController _startDeferredTransitionIfNeeded:] + 688
    9   UIKit                               0x00e54cb9 -[UINavigationController __viewWillLayoutSubviews] + 57
    10  UIKit                               0x00f8e181 -[UILayoutContainerView layoutSubviews] + 213
    11  UIKit                               0x00d84267 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
    12  libobjc.A.dylib                     0x021ca81f -[NSObject performSelector:withObject:] + 70
    13  QuartzCore                          0x005622ea -[CALayer layoutSublayers] + 148
    14  QuartzCore                          0x005560d4 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
    15  QuartzCore                          0x00555f40 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
    16  QuartzCore                          0x004bdae6 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
    17  QuartzCore                          0x004bee71 _ZN2CA11Transaction6commitEv + 393
    18  QuartzCore                          0x004bf544 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
    19  CoreFoundation                      0x0323c4ce __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
    20  CoreFoundation                      0x0323c41f __CFRunLoopDoObservers + 399
    21  CoreFoundation                      0x0321a344 __CFRunLoopRun + 1076
    22  CoreFoundation                      0x03219ac3 CFRunLoopRunSpecific + 467
    23  CoreFoundation                      0x032198db CFRunLoopRunInMode + 123
    24  GraphicsServices                    0x034ce9e2 GSEventRunModal + 192
    25  GraphicsServices                    0x034ce809 GSEventRun + 104
    26  UIKit                               0x00d19d3b UIApplicationMain + 1225
    27  Skirr                               0x000055a2 main + 130
    28  libdyld.dylib                       0x06896725 start + 0
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 
Community
  • 1
  • 1
JohnWick
  • 241
  • 2
  • 13
  • 2
    Please also share the function -[SlideViewController viewDidLoad]. – HKTonyLee Dec 27 '13 at 12:40
  • The actual crash is when you attempt to put `nil` into an array inside a call to `initWithObjects:count:`. (According to the messages, you also have a problem with setting up your initial view controller.) – Phillip Mills Dec 27 '13 at 12:45
  • 1
    Note, this is the error message for [this question](http://stackoverflow.com/questions/20800108/application-run-on-simulator-but-not-on-device-in-iphone/20800940#20800940), the OP posted the error message in a new question instead of adding it to the original question. – zaph Dec 27 '13 at 12:46
  • @PhillipMills, right but in simulator array is not found nil it is only in device here is the link you would get the actual problem:http://stackoverflow.com/questions/20800108/application-run-on-simulator-but-not-on-device-in-iphone – JohnWick Dec 27 '13 at 12:48
  • Since that error is in relation to the question you have already asked you shouldn't be re-asking the question – Popeye Dec 27 '13 at 12:55
  • Your error occurs on this line `[_slideNavigationController setViewControllers:[NSArray arrayWithObject:initalViewController] animated:NO];` your `initalViewController` is `nil` so it crashes. – Popeye Dec 27 '13 at 13:13

3 Answers3

1

have look at this link from

attempt to insert nil object from objects[0]

you are inserting or handling nil object you can get that line refer given above link

Community
  • 1
  • 1
the1pawan
  • 1,194
  • 9
  • 26
0

The error

* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]'

is occurring because you are trying to add nil value to an NSArray. After looking through your code on the other question the specific line of code that it is crashing on is

[_slideNavigationController setViewControllers:[NSArray arrayWithObject:initalViewController] animated:NO];

It is crashing here because of one of two things

1) initalViewController is nil so when you add it using arrayWithObject it crashes.

or

2) setViewControllers:[NSArray arrayWithObject:initalViewController] is causing the error because [NSArray arrayWithObject:initalViewController] is setting nil to the method setViewControllers: method which takes an NSArray.

I would say it is option (1) that is causing your issue though as the crash happens when arrayWithObject is called.

Popeye
  • 11,839
  • 9
  • 58
  • 91
  • But in simulator it is running perfectly.but in device it's not why? – JohnWick Dec 30 '13 at 05:52
  • Hard to tell really without more information but ` UIViewController *initalViewController = [self.delegate initialViewController];` is definitely nil. – Popeye Dec 30 '13 at 12:58
  • yeah in device its nil but in simulator how can i make you to find me the solution please eat some spinach and help me – JohnWick Dec 30 '13 at 13:14
  • There isn't much else I can tell from your code. You will have to add some breakpoints and cycle through your code dropping into methods until you find out where exactly it is. What I have included in my answer is all based on the error and code you have provided. – Popeye Dec 30 '13 at 13:17
-1

Check your main.m. The last argument should be set to the name of the class that implements the UIApplicationDelegate protocol OR you can try for last argument like NSStringFromClass([AppDelegate class]).

Please check this link it might help you . click here

Community
  • 1
  • 1
korat prashant
  • 1,523
  • 10
  • 24
  • How is this connected to the exception in the question? – yurish Dec 27 '13 at 12:48
  • Yurish please see the very first line of crash log. – korat prashant Dec 27 '13 at 12:49
  • It's about a root view controller, not about the app delegate. – yurish Dec 27 '13 at 12:50
  • 3
    This has nothing to do with the crash. That first line is more of a warning which will not crash the app at the very least it will just provide a blank screen but it will still run. The second line in the crash log is the error that is causing the crash. This has nothing to do with `AppDelegate` in main.m -1 as incorrect. – Popeye Dec 27 '13 at 12:58
  • 2
    It is pretty clear that `*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]'` is the issue that crashes the app. Notice the words **Terminating app due to uncaught exception ...** – Popeye Dec 27 '13 at 13:01
  • `4 Skirr 0x000093bd -[SlideViewController viewDidLoad] + 1597` this line show actual crash the app.`SlideViewController ` view even not properly load. – korat prashant Dec 27 '13 at 13:03
  • @RahulShrimali you added any conditional code in `didFinishLaunchingWithOptions` to launch the app ? – korat prashant Dec 27 '13 at 13:06
  • 1
    @prashant So what does that have to do with main.m? The error occurs in `-[SlideViewController viewDidLoad]` `viewDidLoad` being the method being called. At which point in that method this `+[NSArray arrayWithObject:]` is being called `arrayWithObjects`. So when this is being called they are trying to add a `nil` value to the array which is being accepted.Which is the reason for `attempt to insert nil object` So this has nothing to do with what your answer is talking about in main.m. – Popeye Dec 27 '13 at 13:10
  • Also who cares what happens in `didFinishLaunchingWithOptions` they need to be pointing a breakpoint in the `viewDidLoad` in `SlideViewController`. Really all they need to do is look for where the array is being created in `viewDidLoad` and stick a breakpoint at that array. – Popeye Dec 27 '13 at 13:11
  • There error occurs on `[_slideNavigationController setViewControllers:[NSArray arrayWithObject:initalViewController] animated:NO];` which is being called in `viewDidLoad` the `initalViewController` is `nil`. – Popeye Dec 27 '13 at 13:16
  • @Rahul please check the above link which help you a lot. – korat prashant Jan 23 '14 at 05:40