ios - Modify the value of an object in an array in Swift -
I have a problem specifying an object inside an array.
Let me know what I did. Archive is a straight:
Collection collection {var selection: Int = -1}
Object is an object that contains an array of archive objects, and it is also a straight:
structure object {var archive: [archive]
If I am using the following code, then the value is not specified:
Selection on the fun (index int, selected index int) {var collection = Self.object.collection [ind Bus] collection. Selection = selected index}
This is probably because I have a value type in array swift.
Then I changed my code:
selected on the fun (index, selected index) {self.object.collection [index] .selection = selectedIndex}
Then I received a compilation error, the error message is:
/ version / Macintosh HD / User / Public / Projects / Test / Controller / MyViewController.swift: 214: 9: '@lvalue $ T8' is not equal to "int"
What happened? What should I do to assign the value of the object inside my array? Thanks
Edit
I added two methods to my Dropbox. IF If you are interested please try one Thanks!
This code is working well for me:
struct Collection {var selection: int = -1} straight object {var collection: [archive]} var object = object (collection: [collection (selection: 0)]) arch = object collection [0] archive. Selection = 1 Object Kualction [0]. Section 1. 0 Object.Cololution [0] .Seabing = 2 Object Kylie [0]. Select from // 2
The selected index and index Your code? It seems that one of them is causing a problem. You may have to convert them to int like selected code.
Comments
Post a Comment