Search code examples
objective-ccocoa-touchibactionabort

How do you "abort" a method in Objective C?


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.


Solution

  • It's simple:

    return;

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