Jos*_*iah 3 cocoa-touch objective-c abort ibaction
我知道有办法解决这个问题,但我想知道以下问题是否可行.你可以"中止"Objective-C中的方法吗?在这种情况下,它是在Cocoa Touch上.我有一个IBAction.在那个动作中我有if/else if/else语句.如果是其他,我想中止该方法的其余部分.有点像返回0,但对于IBAction.
这可能吗?如果是这样,你将如何实现这一目标.整个方法有点长,但这是我正在看的部分:
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.
}
Run Code Online (Sandbox Code Playgroud)
谢谢.
| 归档时间: |
|
| 查看次数: |
1326 次 |
| 最近记录: |