Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

DennisBlah

macrumors 6502
Original poster
Dec 5, 2013
485
2
The Netherlands
Just as my title already says.
My method looks a bit like this.
Sorry the code is really not related.

Code:
-(void)updateData {
  //Loading current data in plist
  //Doing some preperations and styling

  //If we don't have network connection or host is offline
    //Exit this function and init error viewcontroller

  //checking current data with online data and update
  //whilst we stay on this viewcontroller
}

How to exit the method after I'm initializing my next viewcontroller?
 
Last edited:
You can return... Or I'm pretty sure there's an implicit return at the end of a method that's declared as returning void.
 
Your Pseudocode suggested you wanted to return early. For those cases you can do a simple return when void is involved or return a value of the return type of the method or function.

Personally I try to avoid early returns as it can get messy to keep track of them in a large method. Knowing there is one return location at the end of the block of code means I only have to look there for the result.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.