iOS navigationController pushViewController - SIGABRT error

kubo

macrumors newbie
Original poster
Jan 2, 2012
1
0
Hi

I'm new to object-c/cocoa, so please try pointing the answers so. I have problem call the pushViewController method. I have simple one view project (probabli not the best choice) with storyBoard. Then i add NavigationController to the storyBoard and change the InitialViewControler to it. Then i put a button on the FirstViewControler which is the rootViewController. I wan load the next viewControler from the StoryBoard so i add the code to the button.

Code:
vcSecond *NextView = [[vcSecond alloc] initWithNibName:@"vcSecond" bundle:nil];
[[self navigationController] pushViewController:NextView animated:YES];
The NavigationControler is poited corectly and is not nil. The vcSecond viewController is allocated correctly.

But i get the error SIGABRT. I have been looking for the correct answer but without luck. Could someone help me to work it out.
 

xStep

macrumors 68020
Jan 28, 2003
2,013
100
Less lost in L.A.
My experience with story boards has been faulty so far, so I can't help with that. I'm just going to comment on a programming convention.

You have begun your variable name with and upper case letter and your class with lower case letter. The opposite is the convention. So, NextView should be nextView. The class vcSecond should start with an upper case V and since I'm assuming VC stands for ViewController, it should be VCSecond.

When I place an abbreviated hint like VC in my class names, I place it at the end instead of the beginning. So I would have named that one SecondVC. The important thing is that you follow a convention for your own code.
 

jnoxx

macrumors 65816
Dec 29, 2010
1,343
0
Aartselaar // Antwerp // Belgium
Also, please use some coding conventions (if there is a chance of other developers working with you in the long run..)

And I quote
vcSecond *NextView = [[vcSecond alloc] initWithNibName:mad:"vcSecond" bundle:nil];
[[self navigationController] pushViewController:NextView animated:YES]
vcSecond -> This is your className, this should be Capital for starters, and your pointer NAME, which in your case is NextView, should be LOWER case for starters.. This is quite confusing for other developers ;)
Also (this is not a mistake, just pointing it out), you are using []-syntax for calling getters, but this is not actually needed, because this is Objective C 1.1 syntax, and in the (newer) Objective C 2.0 syntax, you can use the DOT notation like this
[self.navigationController ...]

Hope that made sence
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.