Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you "abort" a method in Objective C? [closed]

I know there are ways around this, but I would like to know if the following question is possible. Can you "abort" a method in Objective-C? In this case it is on Cocoa Touch. I have an IBAction. In that action I have in if/else if/else statement. If it is else, I would like to abort the rest of the method. Kind of like return 0, but for an IBAction.

Is this possible? If so, how would you accomplish this. The entire method is kind of long, but here is the part I am looking at:

if ([unitType isEqualToString:@"mg/dl"])
    {
        //Unit is mg.
        typeOfUnit = unitType;
    }
    else if ([unitType isEqualToString:@"mmol"])
    {
        //Unit is mmol
        typeOfUnit = unitType;
    }
    else
    {
        //Apparently either a bug or a (null) item.
        typeOfUnit = @"mg/dl";
        [[LEItemStore sharedStore] createItem];
        item = [[[LEItemStore sharedStore] allItems] objectAtIndex:0];
        [self loadItems:self];

        //Code to Abort the rest of the method here.
    }

Thanks.

like image 604
Josiah Avatar asked Feb 27 '26 02:02

Josiah


1 Answers

It's simple:

return;

(So simple, that it's too short to post without this sentence.)

like image 119
paulmelnikow Avatar answered Feb 28 '26 16:02

paulmelnikow



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!