This Question have 2 answers right now.

For in loop in swift with dynamic range

By : Duarte

In swift, I always used the C notation like:

for (var i=0;i<mybuffer.count;i++) {}

Now in 3.0 this can not be used. The problem is that using

for i in..<mybuffer.count {} 

will not check the value of mybuffer.count for each iteration, which leads to index out of range, in case the mybuffer.count changes.

Is there a way to overcome this?

I could use a while statement, but I guess that there must be a way to have a for in loop with a dynamic range, right?

By : Duarte


One alternative would be to use a while loop:

var i = 0
while i < mybuffer.count {
    // do stuff
    i += 1
By : rmaddy

How about call updateJSON in callback of updateHash

updateHash: function updateHash(){
        var hashR = data.responseJSON;

updateJSON: function(hash){
    //This is an asynchronous call
        var stepJ = jQuery.parseJSON(data.responseJSON);
        this.setState({json: stepJ,hash});
By : Guigui

Video about For in loop in swift with dynamic range