@@ -11,7 +11,7 @@ final class SportsGround: NSObject, Codable, MKAnnotation, Identifiable {
1111 let createDate , modifyDate : String ?
1212 let latitude , longitude : String
1313 let name : String ?
14- let photos : [ Photo ] ?
14+ var photosOptional : [ Photo ] ?
1515 let preview : String ?
1616 let usersTrainHereCount : Int ?
1717 var usersTrainHereText : String {
@@ -65,16 +65,17 @@ final class SportsGround: NSObject, Codable, MKAnnotation, Identifiable {
6565 case commentsCount = " comments_count "
6666 case countryID = " country_id "
6767 case createDate = " create_date "
68- case id, latitude, longitude, name, photos , preview
68+ case id, latitude, longitude, name, preview
6969 case usersTrainHereCount = " trainings "
7070 case commentsOptional = " comments "
71+ case photosOptional = " photos "
7172 case modifyDate = " modify_date "
7273 case typeID = " type_id "
7374 case trainHereOptional = " train_here "
7475 case usersTrainHere = " users_train_here "
7576 }
7677
77- init ( id: Int , typeID: Int , sizeID: Int , address: String ? , author: UserResponse ? , cityID: Int ? , commentsCount: Int ? , countryID: Int ? , createDate: String ? , modifyDate: String ? , latitude: String , longitude: String , name: String ? , photos : [ Photo ] ? , preview: String ? , usersTrainHereCount: Int ? , commentsOptional: [ CommentResponse ] ? , usersTrainHere: [ UserResponse ] ? , trainHere: Bool ? ) {
78+ init ( id: Int , typeID: Int , sizeID: Int , address: String ? , author: UserResponse ? , cityID: Int ? , commentsCount: Int ? , countryID: Int ? , createDate: String ? , modifyDate: String ? , latitude: String , longitude: String , name: String ? , photosOptional : [ Photo ] ? , preview: String ? , usersTrainHereCount: Int ? , commentsOptional: [ CommentResponse ] ? , usersTrainHere: [ UserResponse ] ? , trainHere: Bool ? ) {
7879 self . id = id
7980 self . typeID = typeID
8081 self . sizeID = sizeID
@@ -88,7 +89,7 @@ final class SportsGround: NSObject, Codable, MKAnnotation, Identifiable {
8889 self . latitude = latitude
8990 self . longitude = longitude
9091 self . name = name
91- self . photos = photos
92+ self . photosOptional = photosOptional
9293 self . preview = preview
9394 self . usersTrainHereCount = usersTrainHereCount
9495 self . commentsOptional = commentsOptional
@@ -97,7 +98,7 @@ final class SportsGround: NSObject, Codable, MKAnnotation, Identifiable {
9798 }
9899
99100 convenience init ( id: Int ) {
100- self . init ( id: id, typeID: . zero, sizeID: . zero, address: nil , author: nil , cityID: nil , commentsCount: nil , countryID: nil , createDate: nil , modifyDate: nil , latitude: " " , longitude: " " , name: nil , photos : nil , preview: nil , usersTrainHereCount: nil , commentsOptional: nil , usersTrainHere: nil , trainHere: nil )
101+ self . init ( id: id, typeID: . zero, sizeID: . zero, address: nil , author: nil , cityID: nil , commentsCount: nil , countryID: nil , createDate: nil , modifyDate: nil , latitude: " " , longitude: " " , name: nil , photosOptional : nil , preview: nil , usersTrainHereCount: nil , commentsOptional: nil , usersTrainHere: nil , trainHere: nil )
101102 }
102103}
103104
@@ -135,6 +136,10 @@ struct CommentResponse: Codable, Identifiable, Hashable {
135136}
136137
137138extension SportsGround {
139+ var photos : [ Photo ] {
140+ get { photosOptional ?? [ ] }
141+ set { photosOptional = newValue }
142+ }
138143 var comments : [ CommentResponse ] {
139144 get { commentsOptional ?? [ ] }
140145 set { commentsOptional = newValue }
@@ -155,6 +160,6 @@ extension SportsGround {
155160 || commentsCount. valueOrZero > . zero && !comments. isEmpty
156161 }
157162 static var emptyValue : SportsGround {
158- . init( id: . zero, typeID: . zero, sizeID: . zero, address: nil , author: . emptyValue, cityID: nil , commentsCount: nil , countryID: nil , createDate: nil , modifyDate: nil , latitude: " " , longitude: " " , name: nil , photos : [ ] , preview: nil , usersTrainHereCount: . zero, commentsOptional: nil , usersTrainHere: [ ] , trainHere: nil )
163+ . init( id: . zero, typeID: . zero, sizeID: . zero, address: nil , author: . emptyValue, cityID: nil , commentsCount: nil , countryID: nil , createDate: nil , modifyDate: nil , latitude: " " , longitude: " " , name: nil , photosOptional : [ ] , preview: nil , usersTrainHereCount: . zero, commentsOptional: nil , usersTrainHere: [ ] , trainHere: nil )
159164 }
160165}
0 commit comments