0
UserDefaults를 사용하여 일련의 문자열을 추가하고 저장하려고하는데 코드가 호출 될 때마다 배열에 추가하는 대신 데이터를 대체합니다. 있어야 할 곳에 없는?신속한 사용자 기본 배열에 값을 추가하는 방법
if Plus == true
{
if typeOfMath != [""]
{
typeOfMath.append("Addition")
UserDefaults.standard.set(typeOfMath, forKey: "typeMath")
print ("\(typeOfMath)")
typeOfMath = [""]
}
}
고맙습니다! 내가 추가 한 경우 VAR mathData = UserDefaults.standard.stringArray (forKey : "typeMath") { mathData.append ("\ (typeOfMath)") typeOfMath = mathData } 내 데이터는 다음과 같습니다 : [ "추가" "[\"추가 \ "]", "[\"추가 \ "]"], [ "추가", "추가", "추가"]와 같이 보이도록 괄호를 제거하는 방법은 무엇입니까? –
@ Daniel.wu이 'mathData.append (contentsOf : typeOfMath)' – 3stud1ant3
이 효과가 있다고 생각합니다! 고맙습니다! –