Swift: Cannot Store Unsafe Pointers in Array -


I created a small struct to capture the version number.

Now I've discovered compact ways to parse the numbers directly into the stream of straight and I tried to apply it this way:

  struct version {var major : Int = 0 var minor: int = 0 var revision: int = 0 init (string: string) {let components = string .componentsSeparatedByString (".") If 1 ... 3 ~ = components.count {var target = [ & Amp; Key, and short, and revision] for index 0 ... 2 {var scanner = NSScanner (string: element [index]) if (! Scanner.scanInteger (target [index]) {major = 0 minor = 0 revision = 0 return}}}}}   

But I get the error message:

  The type of '[inout int]' variable is not possible   

I do not have this error. What is the method of implementing this kind of use in a member variable using such signals?

Update

Finally I did not use insecure pointers. This was my last implementation:

  init (string: string) {component = string .componentsSeparatedByString (".") If 1 ... 3 ~ = components.count {var value = 0 for 0, 0, 0] index .. .. Components.count {var scanner = NSScanner (string: component [index]) (! Scanner.scan intiger (and value [index]) {return}} key = value [0] small = value [1] amendment = value [2]}}    

not in-out Unsafe indicator and unprotected user , only accepts the function unsafe ??? Indicator & lt; T & gt; Family logic, in-out expression will be passed as related indicator type. See:

Try this:

  var target: [int] = [0,0,0]; For the index 0 ... 2 {var scanner = NSScanner (string: component [index]) if (! Scanner.scx integer (& target [index]) {major = 0 minor = 0 revision = 0 return} } Target = [0] Mild = Goal [1] Modification = Goal [2]   

OR Target: [Unsecured Poointer & lt; Int & gt;] = [] Targets.append (and prominent) targets.append (and smaller) for the targets.append (& amp; modification) index ... 2 {var scanner = NSScanner (string: component [index ]) If (! Scanner .scanInteger (target [index]) {major = 0 minor = 0 revision = 0 return}}

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -