Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Foundation
- class MyOwnViewController: UIViewController {
- @IBOutlet var showOption3: UILabel!
- @IBOutlet var showOption4: UILabel!
- override func viewDidLoad() {
- super.viewDidLoad()
- var voteCount1 = PFObject(className: "VoteCount")
- voteCount1["choices"] = 2
- voteCount1["votes"] = Int()
- voteCount1["votes2"] = Int()
- voteCount1["optionName"] = String()
- voteCount1["optionName2"] = String()
- voteCount1["objectId"] = String()
- voteCount1["pollNumber"] = Int()
- var query = PFQuery(className: "VoteCount")
- query.countObjectsInBackgroundWithBlock {
- (count: Int32, error: NSError!) -> Void in
- if error == nil {
- let randNumber = Int(arc4random_uniform(UInt32(count)))
- query.whereKey("pollNumber", equalTo: randNumber)
- query.getFirstObjectInBackgroundWithBlock {
- (voteCount1: PFObject!, error: NSError!) -> Void in
- if error != nil {
- NSLog("%@", error)
- } else {
- let votes = voteCount1["votes"] as Int
- let votes2 = voteCount1["votes2"] as Int
- let option1 = voteCount1["optionName"] as String
- let option2 = voteCount1["optionName2"] as String
- self.showOption3.text = "(option1)"
- self.showOption4.text = "(option2)"
- }
- }
- } else {
- println("error (error)")
- }
- }
- }
- override func didReceiveMemoryWarning() {
- super.didReceiveMemoryWarning()
- // Dispose of any resources that can be recreated.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement