Set name and url in Password non-optional
Name and url in Password class shouldn't be optional because we store them in core data as non-optional. This change also help us to avoid man unneccessary unwrap.
This commit is contained in:
parent
5262ca89f7
commit
2abbceb2e9
9 changed files with 60 additions and 39 deletions
|
|
@ -37,9 +37,27 @@ extension PasswordEntity {
|
|||
}
|
||||
|
||||
public func getURL() -> URL? {
|
||||
if let p = path {
|
||||
return URL(string: p.stringByAddingPercentEncodingForRFC3986()!)
|
||||
if let p = getPath().stringByAddingPercentEncodingForRFC3986() {
|
||||
return URL(string: p)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// XXX: define some getters to get core data, we need to consider
|
||||
// manually write models instead auto generation.
|
||||
|
||||
public func getImage() -> Data? {
|
||||
return image
|
||||
}
|
||||
|
||||
public func getName() -> String {
|
||||
// unwrap non-optional core data
|
||||
return name ?? ""
|
||||
}
|
||||
|
||||
public func getPath() -> String {
|
||||
// unwrap non-optional core data
|
||||
return path ?? ""
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue