我需要从数据库中读取 3 个值并在一个方法中返回它们。我很难理解如何使用 NSInteger 类型返回值。这是代码:
NSString* GetVerbInfinitive(FMDatabase* mydb, NSString* myConjugation, NSInteger verbal_time, NSInteger verbal_person)
{
NSMutableString *ret = [[NSMutableString alloc] initWithString:@""];
FMResultSet *rs = [mydb executeQuery:@"select verb_text, conjugation_verbal_time, conjugation_verbal_person from verbs where verb_conjugation = ?",[[myConjugation lowercaseString] precomposedStringWithCanonicalMapping]];
if ([rs next])
{
if (![rs columnIndexIsNull:0])
{
[ret setString:[rs stringForColumn:@"verb_text"]];
verbal_time = [rs intForColumn:@"conjugation_verbal_time"];
verbal_person = [rs intForColumn:@"conjugation_verbal_person"];
}
else
{
NSLog(@"GetVerbInfinitive: verb '%@' has no infinitive defined", myConjugation);
}
}
[rs close];
return [ret autorelease];
}
当我返回调用方法时,NSInteger 值仅在方法内部起作用,它们丢失了。我相信我应该通过引用传递这些 NSInteger,但我不知道如何。我不想为此创建类型结构。
谢谢,米格尔