Move get category text logic to model

This commit is contained in:
Bob Sun 2017-03-10 23:01:56 -08:00
parent d82396a322
commit ff947f8e17
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4
2 changed files with 12 additions and 12 deletions

View file

@ -27,4 +27,15 @@ extension PasswordEntity {
let encryptedData = try pgp.encryptData(plainData, usingPublicKey: pgp.getKeysOf(.public)[0], armored: false)
return encryptedData
}
func getCategoryText() -> String {
var parentEntity = parent
var passwordCategoryArray: [String] = []
while parentEntity != nil {
passwordCategoryArray.append(parentEntity!.name!)
parentEntity = parentEntity!.parent
}
passwordCategoryArray.reverse()
return passwordCategoryArray.joined(separator: " > ")
}
}