0

Trying to access and set my cells textLabel and detail text label to objects i have appended to the array. Im not to sure how to use the right syntax in this case. thanks for the help!

heres the objects I've appended from parse in my for loop.

var customers = [String]()


 for object in objects {

self.customers.append(object["customerName"] as! String)
self.customers.append(object["customerStreetAddress"] as! String)

  cellForRowAtIndexPath {


cell.textLabel.text = //I want the objects["customerName"] here
cell.detailTextLabel.text = // objects["customerStreetAddress"] here
}

1 Answer 1

1

You could try this.

var customers = [String]()
var number = -1

for object in objects {

    self.customers.append(object["customerName"] as! String)
    self.customers.append(object["customerStreetAddress"] as! String)

    cellForRowAtIndexPath {

        ++number
        if number + 1 <= customers.count {
            cell.textLabel.text = customers[number]//I want the objects["customerName"] here
        }
        ++number
        if number + 1 <= customers.count {
            cell.detailTextLabel.text =  customers[number]// objects["customerStreetAddress"] here
        }
    }
}
Sign up to request clarification or add additional context in comments.

3 Comments

Hey bud thanks for the reply, this works only if i want to display the first and second object over and over again but not every object thats in that FOR loop. how can i get all the customer name and street addresses that are in that for loop? thanks again!
perfect thanks man! never used those types of values before....thats new to me :) where can i learn more about that?? any good articles or links?thanks man!
Actually, you can go on youtube and watch Stanford lectures and you will learn a lot from him. Here is the link youtube.com/playlist?list=PLy7oRd3ashWodnpf8rjfYEkTgwbOEsKfU. But, for this, specifically, try looking into the documentation here is the link. developer.apple.com/library/ios/documentation/Swift/Conceptual/… & developer.apple.com/library/ios/documentation/Swift/Conceptual/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.