gpt4 book ai didi

ios - 如何使 PFSignupViewController 中的字段之一可选

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

我正在使用 this tutorial设置我的 Parse 应用程序的注册 View ,我想使用 additionalField,但我希望它是一个可选字段。 MySignUpViewController 检查以确保在提交之前填写所有字段的方式如下:

// Sent to the delegate to determine whether the sign up request should be submitted to the server.
- (BOOL)signUpViewController:(PFSignUpViewController *)signUpController shouldBeginSignUp:(NSDictionary *)info {
BOOL informationComplete = YES;

// loop through all of the submitted data
for (id key in info) {
NSString *field = [info objectForKey:key];
if (!field || !field.length) { // check completion
informationComplete = NO;
break;
}
}

// Display an alert if a field wasn't completed
if (!informationComplete) {
[[[UIAlertView alloc] initWithTitle:@"Missing Information" message:@"Make sure you fill out all of the information!" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil] show];
}

return informationComplete;
}

这意味着它循环遍历所有字段并要求它们都包含某些内容才能进入下一步。我如何告诉该循环在循环时忽略 additionalField

最佳答案

目标是使 informationComplete = YES。为此,您可以执行以下操作:

// loop through all of the submitted data
for (id key in info) {
if (![key isEqualToString:@"KEYTOIGNORE"]) { //IF the key is not equal to specified string continue execution
NSString *field = [info objectForKey:key];
if (!field || !field.length) { // check completion
informationComplete = NO;
break;
}
}
}

这将防止检查您要忽略的字段以查看它是否为空。所以只要弄清楚它的关键是什么,然后试一试。让我知道进展如何,祝你好运!

关于ios - 如何使 PFSignupViewController 中的字段之一可选,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26457023/

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