how to loop through elements of array of <UnsafeMutablePointer> in Swift

user1612877

I am new to Swift and wanted to loop through an array of MKMapPoints which I get from an MKPolygon by calling myPoly.points(). However, I am stuck as to how to loop through every element of the C-Array of pointers.

 for element in myPointsArray {} 

does not work and I don't know how determine the number of elements of this kind of array in Swift. Any ideas? Thanks for your help!

Airspeed Velocity

UnsafeBufferPointer presents an unsafe pointer and a count as a collection so you can for..in over it, subscript it safely, pass it to algorithms that work on collections etc:

for point in UnsafeBufferPointer(start: poly.points(), count: poly.pointCount) {
    println("\(point.x),\(point.y)")
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to append all elements of an array to a label through a for loop in Swift

How to loop through an array of objects in swift

How to create UnsafeMutablePointer<UnsafeMutablePointer> in swift

Loop through array with missing elements

Loop through array and associated elements

How to loop through child elements and create nested array of objects?

How to loop through a bash array, excluding certain initial elements?

How can I loop through the elements of the multidimensional array and search for a match?

how to loop through an elements in jquery if the name attribute is an array?

How to loop through 1D array elements multiple times?

How to loop through an array for subset of elements (in reverse order) in perl

loop through array with delay - Swift

How to loop through this array

How to Loop through a list of elements

Loop Through Nested Array Elements With JavaScript

Loop through array as four elements but in a consecutive fashion

Loop through an array and then move some elements

loop through array list to remove specified elements

Polymer loop through an array of elements to be stamped

Swift - How to loop through NSDictionary

How to use UnsafeMutablePointer in Swift 3?

How to use UnsafeMutablePointer<OpaquePointer> in Swift?

How to loop through an array and set of dom elements and add the current item of the array to the current dom element?

how to loop through array with javascript

How to loop through localstorage with array in it?

How to loop through an array of checkbox

How to loop through an array in mongodb?

How to loop through array in jQuery?

How to loop properly through an array?