gpt4 book ai didi

ios - 从基于 alertView 的函数调用 Objective-C 中的函数

转载 作者:行者123 更新时间:2023-11-29 10:59:02 25 4
gpt4 key购买 nike

所以我有一个警报 View ,当我按下进入警报 View 时,它会调用此函数:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 1) {
NSString *name = [alertView textFieldAtIndex:0].text;
// name contains the entered value
NSLog(name);
if(login){
LoginToProfile(name);
} else if(createAccount){
//AddAcount(name);
}

}
}

如您所见,现在在这个方法中我希望它能够调用在调用/创建警报 View 的同一 View Controller 中定义的另一个函数。但是编译器不喜欢这样。

我还收到警告“LoginToProfile 的隐式声明在 C99 中无效”。

我该如何解决这个问题?

最佳答案

那不是您定义的 C 函数。这是一个 obj-c 方法,您需要在对象本身上调用它。你这样调用它 [self LoginToProfile:name]

关于ios - 从基于 alertView 的函数调用 Objective-C 中的函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16871987/

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