다음 코드는 iPhone 6 및 5S 시뮬레이터에서 완벽하게 작동하지만 iPhone 5 시뮬레이터에서이 코드를 실행하려고하면이 코드 줄이 작동하지 않습니다.사용자 정의 사전이 iPhone 5에 값을 설정하지 않습니다
self.groupCollection[creditCadKey] = creditCard
self.groupCollection[homeKey] = home
self.groupCollection[boletoKey] = boleto
사전은 값을 변경하지 않고 비어 있습니다. 나는 이것이 왜 일어나고 있는지 전혀 모른다. 여기에 전체 코드 :
import Foundation
public class Checkout_GroupedPaymentSystem : NSObject {
public var creditCard: [Checkout_PaymentSystem]?
public var home: [Checkout_PaymentSystem]?
public var voucher: [Checkout_PaymentSystem]?
public var boleto: [Checkout_PaymentSystem]?
public let creditCadKey = "Cartão de Crédito"
public let homeKey = "Pagamento em Casa"
public let voucherKey = "Voucher"
public let boletoKey = "Boleto Bancário"
public var groupCollection: [String:[Checkout_PaymentSystem]] = [:]
public init(fromDictionary dictionay: NSDictionary) {
if let creditCardArray = dictionay[creditCadKey] as? [NSDictionary]{
creditCard = [Checkout_PaymentSystem]()
for dic in creditCardArray {
let value = Checkout_PaymentSystem(fromDictionary: dic)
creditCard?.append(value)
}
self.groupCollection[creditCadKey] = creditCard
}
if let homeArray = dictionay[homeKey] as? [NSDictionary]{
home = [Checkout_PaymentSystem]()
for dic in homeArray {
let value = Checkout_PaymentSystem(fromDictionary: dic)
home?.append(value)
}
self.groupCollection[homeKey] = home
}
if let voucherArray = dictionay[voucherKey] as? [NSDictionary]{
voucher = [Checkout_PaymentSystem]()
for dic in voucherArray {
let value = Checkout_PaymentSystem(fromDictionary: dic)
voucher?.append(value)
}
//self.groupCollection[voucherKey] = voucher
}
if let boletoArray = dictionay[boletoKey] as? [NSDictionary]{
boleto = [Checkout_PaymentSystem]()
for dic in boletoArray {
let value = Checkout_PaymentSystem(fromDictionary: dic)
boleto?.append(value)
}
self.groupCollection[boletoKey] = boleto
}
}
}
당신에게 문제가 아이폰 OS의 다른 버전없는 확신은? 각 시뮬레이터에서 사용하는 iOS 버전은 무엇입니까? init의 사전 매개 변수를 인쇄하여 매번 동일한 항목이 있는지 확인하십시오. – deadbeef
모든 시뮬레이터에서 iOS 9.3을 사용하고 있습니다. 또한 사전은 항상 동일합니다. –