在下面的代码中,就成功实现了。只需要一处修改。当应用程序最初打开时,管理员密码应采用默认密码“Hello”,然后当用户有权访问管理员密码时,将对其进行编辑并保存,然后它将位于“管理员密码”键中
我怎样才能在第一次使用默认密码?
func enableSectionAlert() {
let alertController = UIAlertController(title: "Admin Password", message: "Please input admin password", preferredStyle: .alert)
let enable = UIAlertAction(title: "Enable", style: .default) { (_) in
let field = alertController.textFields?[0].text
if let x = UserDefaults.standard.string(forKey: "admin password"), x == field {
self.demosSelectionEnabled()
self.showSection.isUserInteractionEnabled = false
self.showSection.textLabel?.textColor = UIColor.lightGray
}
else{
let wrongPwd = UIAlertController(title: "Wrong Admin Password", message: nil, preferredStyle:UIAlertControllerStyle.alert)
wrongPwd.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.default, handler: nil))
self.present(wrongPwd, animated: true, completion: nil)
}
}
let cancelAction = UIAlertAction(title: "Cancel", …Run Code Online (Sandbox Code Playgroud) 用户名regex应该是至少8个字符长的任何字符串。该字符串中可以有@符号,句点,数字或没有。我在下面放置了一些有效和无效的测试用例。我该如何实现?
有效:
user@user.com
adminuser1
user.user@user.com
Run Code Online (Sandbox Code Playgroud)
无效:
user@user.user.com
1adminuser1
Run Code Online (Sandbox Code Playgroud)
目前我有:
let usernameRegex = "\\A\\w{6,30}\\z"
Run Code Online (Sandbox Code Playgroud) 我有以下 xml 输入:
<root>
<calc>
<arab>42</arab>
</calc>
<calc>
<arab>137</arab>
</calc>
</root>
Run Code Online (Sandbox Code Playgroud)
我想输出以下内容:
<root>
<calc>
<roman>XLII</roman>
<arab>42</arab>
</calc>
<calc>
<roman>CXXXVII</roman>
<arab>137</arab>
</calc>
</root>
Run Code Online (Sandbox Code Playgroud)
通过编写 XSLT。到目前为止,我已经编写了这个 XSLT,但是还需要做什么才能输出正确的输出呢?
Run Code Online (Sandbox Code Playgroud)<?xml version="1.0" encoding="UTF-8"?> <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:num="http://whatever" version="2.0" exclude-result-prefixes="xs num"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <!-- identity transform --> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> </xsl:transform>