gpt4 book ai didi

objective-c - 转到另一个函数中的标签

转载 作者:行者123 更新时间:2023-11-28 18:07:23 24 4
gpt4 key购买 nike

我需要这样做:

-(void)function1{
goto start;
}

-(void)function2{
//some code
start://i need to get in here exactly, [self function2] oblige me to execute the function2 from the beginning
//some code..
}

看来我做不到,我该怎么做呢?提前谢谢。

编辑:这是我的实际代码:

-(void)viewWillAppear:(BOOL)animated{
if (sqlite3_open(dbpath, &contactDB) == SQLITE_OK)
{
NSString *querySQL = [NSString stringWithFormat:
@"Select quiz,question,p1,p2,p3,num_correct from question where quiz=(select id from quiz where nom = \'%@\' and niveau= \'%i\' and theme=(select id from theme where nom=\'%@\'))",nomPartieQuiz,quiIslam.theGameLevel,quiIslam.themeChoisie];

const char *query_stmt = [querySQL UTF8String];

if (sqlite3_prepare_v2(contactDB,
query_stmt, -1, &statement, NULL) == SQLITE_OK)
{
start://étiquette
while (sqlite3_step(statement) == SQLITE_ROW && !passToNextQuestion)
{



NSString *addressField = [[NSString alloc]
initWithUTF8String:
(const char *) sqlite3_column_text(
statement, 1)];

NSLog(@"%@",addressField);
txtView.text=addressField;

passToNextQuestion=NO;

}

sqlite3_finalize(statement);
}
sqlite3_close(contactDB);
}

}


-(IBAction)clickOnTheButton:(id)sender{

btn1.hidden=YES;
goto start;
}

最佳答案

试试这个:

-(void)function1{
[self function2];
}

-(void)function2{

//some code..
}

而且,只有在非常非常特殊的情况下才允许使用“gotos”,你现在应该忘掉它们!它再次适用于任何开发原则。

关于objective-c - 转到另一个函数中的标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9685333/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com