Retrieving firebase children and populating them in a UITableView - ios

Trying to query firebase children and retrieve a snapshot array of their data into a tableview. Not sure if I am implementing this correctly, but I am not the getting a runtime error. However, my tableview is just white with no objects displaying. Some feedback would be helpful. Thanks.
Here is my FB JSON tree structure
Here is my User class (var userList = User)
class CDetailTableViewController: UITableViewController {
static var imageCache = NSCache<AnyObject, UIImage>()
var userList = [User]()
var ref = FIREBASE.FBDataReference().ref
var refHandle: UInt!
override func viewDidLoad() {
super.viewDidLoad()
ref = FIREBASE.FBLink().FBref
configureCell()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return userList.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell") as! CDetailTableViewCell
cell.priceLabel?.text = userList[indexPath.row].priceLabel
cell.titleLabel?.text = userList[indexPath.row].titleLabel
cell.itemPhoto?.image = userList[indexPath.row].objectImage
return cell
}
func configureCell(){
let ref = FIRDatabase.database().reference()
let userID = FIRAuth.auth()?.currentUser?.uid
refHandle = ref.child("Enterpriser Listings").child("Sell Old Stuff - Listings").child(userID!).observe(.childAdded, with: { (snapshot) in
if let dictionary = snapshot.value as? [String : AnyObject] {
print("get dictionary")
print(dictionary)
let user = User()
user.setValuesForKeys(dictionary)
self.userList.append(user)
// Get user value
DispatchQueue.main.async {
print("reloaded")
self.tableView.reloadData()
}
}
})
}
/*
// Override to support conditional editing of the table view.
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
// Return false if you do not want the specified item to be editable.
return true
}
*/
/*
// Override to support editing the table view.
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
// Delete the row from the data source
tableView.deleteRows(at: [indexPath], with: .fade)
} else if editingStyle == .insert {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
*/
/*
// Override to support rearranging the table view.
override func tableView(_ tableView: UITableView, moveRowAt fromIndexPath: IndexPath, to: IndexPath) {
}
*/
/*
// Override to support conditional rearranging of the table view.
override func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool {
// Return false if you do not want the item to be re-orderable.
return true
}
*/
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}

May be the problem is with your Firebase reference, try like this way.
ref.child("Enterpriser Listings").child("Sell Old Stuff - Listings").observe(.value, with: { (snapshot:FIRDataSnapshot) in
var users = [User]()
for child in snapshot.children {
print("\((sweet as! FIRDataSnapshot).value)")
if let dictionary = child.value as? [String : AnyObject] {
let user = User()
user.setValuesForKeys(dictionary)
users.append(user)
}
}
self.userList = users
self.tableView.reloadData()
})

Simple question. Have you delegated your tableview?
class YourController: < other >, UITableViewDataSource, UITableViewDelegate {
#IBOutlet weak var tableView: UITableView!
override func viewDidLoad() { //for example this function
super.viewDidLoad()
self.tableView.delegate = self
self.tableView.dataSource = self
}

Related

Displaying Data from Firebase in TableView Cell

I have the following code in one of my VC's (as part of my larger project). One of my Firebase DB references is called Sell_Request. It has three children (name, latitude and longitude), but I'm only concerned with name for right now.
I am trying to add it to a String array and am also printing it to the console. I am seeing the names being printed to the console, but I'm not getting the names printed in the individual cells.
Thanks for looking.
import UIKit
import Firebase
import FirebaseDatabase
import MapKit
import CoreLocation
class RequestVC: UITableViewController, CLLocationManagerDelegate {
var locationManager = CLLocationManager()
var sellerUserNames = [String]()
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "backToMain" {
self.navigationController?.navigationBar.isHidden = true
}
}
override func viewDidLoad() {
super.viewDidLoad()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestWhenInUseAuthorization()
locationManager.startUpdatingLocation()
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
if let location = manager.location?.coordinate {
let databaseRef = FIRDatabase.database().reference()
databaseRef.child("Sell_Request").queryOrderedByKey().observe(.childAdded, with: { (FIRDataSnapshot) in
if let data = FIRDataSnapshot.value as? NSDictionary {
if let name = data[Constants.NAME] as? String {
self.sellerUserNames.append(name)
print(name)
}
}
})
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return sellerUserNames.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
cell.textLabel?.text = sellerUserNames[indexPath.row]
return cell
}
/*
// Override to support conditional editing of the table view.
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
// Return false if you do not want the specified item to be editable.
return true
}
*/
/*
// Override to support editing the table view.
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
// Delete the row from the data source
tableView.deleteRows(at: [indexPath], with: .fade)
} else if editingStyle == .insert {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
*/
/*
// Override to support rearranging the table view.
override func tableView(_ tableView: UITableView, moveRowAt fromIndexPath: IndexPath, to: IndexPath) {
}
*/
/*
// Override to support conditional rearranging of the table view.
override func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool {
// Return false if you do not want the item to be re-orderable.
return true
}
*/
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
You just need to call tableView.reloadData() after you append the name to the sellerUserNames array, change your function to this...
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
if let location = manager.location?.coordinate {
let databaseRef = FIRDatabase.database().reference()
sellerUserNames.removeAll()
databaseRef.child("Sell_Request").queryOrderedByKey().observe(.childAdded, with: { (FIRDataSnapshot) in
if let data = FIRDataSnapshot.value as? NSDictionary {
if let name = data[Constants.NAME] as? String {
self.sellerUserNames.append(name)
print(name)
self.tableView.reloadData()
}
}
})
}
}
Edit
where/when you want to call sellerUserNames.removeAll() depends on your code and the life cycle of your table view, but I have edited my code above to add it in where it is most likely appropriate.
TableView need to reload after data source has changes i.e sellerUserNames in your code. So after you append the name to sellerUserNames, you need to reload the tableview.
Add this line of code after you append the name.
self.tableView.reloadData()

load images made slow my tableview

I got my data from a json url, but when I want to load my images, it is very slowly !
class NewsTableViewController: UITableViewController {
var ids = [String]()
var titles = [String]()
var descriptions = [String]()
var images = [String]()
var links = [String]()
var dates = [String]()
#IBOutlet var table_news: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
table_news.delegate = self
getNews()
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return self.ids.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell:NewsTableViewCell = self.tableView.dequeueReusableCell(withIdentifier: "news_cell") as! NewsTableViewCell
cell.lbl_date.text = self.dates[indexPath.row]
cell.lbl_title.text = self.titles[indexPath.row]
var des = self.descriptions[indexPath.row]
if des.characters.count > 200 {
let range = des.rangeOfComposedCharacterSequences(for: des.startIndex..<des.index(des.startIndex, offsetBy: 200))
let tmpValue = des.substring(with: range).appending("...")
cell.lbl_des.text = tmpValue
}
DispatchQueue.main.async{
cell.img_news.setImageFromURl(stringImageUrl: self.images[indexPath.row])
}
return cell
}
/*
// Override to support conditional editing of the table view.
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
// Return false if you do not want the specified item to be editable.
return true
}
*/
/*
// Override to support editing the table view.
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
// Delete the row from the data source
tableView.deleteRows(at: [indexPath], with: .fade)
} else if editingStyle == .insert {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
*/
/*
// Override to support rearranging the table view.
override func tableView(_ tableView: UITableView, moveRowAt fromIndexPath: IndexPath, to: IndexPath) {
}
*/
/*
// Override to support conditional rearranging of the table view.
override func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool {
// Return false if you do not want the item to be re-orderable.
return true
}
*/
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
func getNews() {
RestApiManager.sharedInstance.getNews { (json: JSON) in
if let results = json.array {
for entry in results {
self.ids.append(entry["id"].string!)
self.titles.append(entry["title"].string!)
self.descriptions.append(entry["description"].string!)
self.images.append(entry["images"].string!)
self.links.append(entry["link"].string!)
self.dates.append(entry["date"].string!)
}
DispatchQueue.main.async{
self.table_news.reloadData()
}
}
}
}
}
custom cell:
extension UIImageView{
func setImageFromURl(stringImageUrl url: String){
if let url = NSURL(string: url) {
if let data = NSData(contentsOf: url as URL) {
self.image = UIImage(data: data as Data)
}
}
}
}
class NewsTableViewCell: UITableViewCell {
#IBOutlet weak var img_news: UIImageView!
#IBOutlet weak var lbl_title: UILabel!
#IBOutlet weak var lbl_date: UILabel!
#IBOutlet weak var lbl_des: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
lbl_des.lineBreakMode = .byWordWrapping // or NSLineBreakMode.ByWordWrapping
lbl_des.numberOfLines = 0
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
I'm using an extension image view.
The problem for the slowness you are mentioning are in the UIImageView extension
extension UIImageView{
func setImageFromURl(stringImageUrl url: String){
if let url = NSURL(string: url) {
if let data = NSData(contentsOf: url as URL) {
self.image = UIImage(data: data as Data)
}
}
}
}
In the NSData(contentsOf: url as URL) you are retrieving the contents of the URL synchronously from the network, blocking the main thread. You can download the content using a NSURLSession with an asynchronous callback or using some 3rd party libraries (SDWebImage probably being the most used and battle tested).

Table View Data Source not showing all the rows

I am a seasoned web and Android developer and am teaching myself iPhone development on my MacBook running xCode 8.2 using the book Beginning iPhone Development with Swift 2. I am running into issues converting the examples in the book to Swift 3, but have been able to deal with most of them.
The tables are not going well, however. I have converted all of the methods I can figure out, but I can't get all of the table data to show on any of the examples. Here is my code:
//
// RootViewController.swift
// Fonts
//
// Created by Thomas Hehl on 12/21/16.
//
import UIKit
class RootViewController: UITableViewController {
private var familyNames: [String]!
private var cellPointSize: CGFloat!
private var favoritesList: FavoritesList!
private static let familyCell = "FamilyName"
private static let favoritesCell = "Favorites"
override func viewDidLoad() {
super.viewDidLoad()
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem()
familyNames = (UIFont.familyNames as [String]).sorted()
let preferredTableViewFont = UIFont.preferredFont(forTextStyle: UIFontTextStyle.headline)
cellPointSize = preferredTableViewFont.pointSize
favoritesList = FavoritesList.sharedFavoritesList
tableView.estimatedRowHeight = cellPointSize
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
tableView.reloadData()
}
func fontForDisplay(atIndexPath indexPath: NSIndexPath) -> UIFont? {
if indexPath.section == 0 {
let familyName = familyNames[ indexPath.row]
let fontName = UIFont.fontNames(forFamilyName: familyName).first
return fontName != nil ? UIFont(name: fontName!, size: cellPointSize) : nil
} else {
return nil
}
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
// return the number of sections
return favoritesList.favorites.isEmpty ? 1 : 2
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return section == 0 ? familyNames.count : 1
}
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return section == 0 ? "All Font Families" : "My Favorite Fonts"
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.section == 0 {
// the font names list
let cell = tableView.dequeueReusableCell(withIdentifier: RootViewController.familyCell, for: indexPath)
cell.textLabel?.font = fontForDisplay(atIndexPath: indexPath as NSIndexPath)
cell.textLabel?.text = familyNames[indexPath.row]
cell.detailTextLabel?.text = familyNames[indexPath.row]
return cell
} else {
//the favorites list
return tableView.dequeueReusableCell(withIdentifier: RootViewController.favoritesCell, for: indexPath)
}
}
/*
// Override to support conditional editing of the table view.
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
// Return false if you do not want the specified item to be editable.
return true
}
*/
/*
// Override to support editing the table view.
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
// Delete the row from the data source
tableView.deleteRows(at: [indexPath], with: .fade)
} else if editingStyle == .insert {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
*/
/*
// Override to support rearranging the table view.
override func tableView(_ tableView: UITableView, moveRowAt fromIndexPath: IndexPath, to: IndexPath) {
}
*/
/*
// Override to support conditional rearranging of the table view.
override func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool {
// Return false if you do not want the item to be re-orderable.
return true
}
*/
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
Unfortunately, even though that familyNames contains 75 entries, the table is only showing the first screenful. Here is the screenshot.
As you can see, the scrollbar's all the way at the bottom, but that's not nearly all of the fonts.
[EDIT - After chat, it appears the problem is merely that the OP doesn't know how to scroll. The OP sent me the actual project, I ran it, and it works just fine.]
Your code works fine. I literally just copied and pasted your code into the Master-Detail template, made a few adjustments (commenting out the second section stuff because you didn't supply any info about it), and got this:

Table View only loads if I put phone in landscape mode

I have a custom table view, which when I run the app, shows up blank, like it hasnt been loaded, but when I tilt my phone to landscape mode, the entries appear, which really doesnt make sense to me. Any suggestions?
Edit: Here is my code
import UIKit
import Alamofire
import ObjectMapper
class LotteryTableViewController: UITableViewController {
let lotteryMachine = LotteryMachine()
var currentStandings: [Team] = []
var draftStandings: [Team] = []
override func viewDidLoad() {
super.viewDidLoad()
let headers = [
"User-agent": "LotteryMachine/1.0 (nilayneeranjun24#gmail.com)",
]
Alamofire.request(.GET, "https://erikberg.com/nba/standings.json",headers: headers)
.responseJSON { response in
let parentJson = Mapper<Standings>().map(response.2.value)
let standingsArray: [Team] = parentJson!.standing!
self.currentStandings=standingsArray
self.draftStandings=self.lotteryMachine.setPossibleCombinations(standingsArray)
self.draftStandings=self.lotteryMachine.setDraftPositions(self.draftStandings)
print (self.draftStandings.toJSON())
}
}
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem()
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Table view data source
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return draftStandings.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cellIdentifier = "LotteryTableViewCell"
let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) as! LotteryTableViewCell
let position = self.draftStandings[indexPath.row].draftingPosition!
let teamName = self.draftStandings[indexPath.row].lastName!
let record = String(self.draftStandings[indexPath.row].won!) + "-" + String(self.draftStandings[indexPath.row].lost!)
let player = "Ben Simmons"
cell.position.text = String(position)
cell.teamName.text = teamName
cell.record.text = String(record)
cell.player.text = player
cell.teamLogo.image = UIImage(named: "lakers")
// Configure the cell...
return cell
}
/*
// Override to support conditional editing of the table view.
override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
// Return false if you do not want the specified item to be editable.
return true
}
*/
/*
// Override to support editing the table view.
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
if editingStyle == .Delete {
// Delete the row from the data source
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
} else if editingStyle == .Insert {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
*/
/*
// Override to support rearranging the table view.
override func tableView(tableView: UITableView, moveRowAtIndexPath fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath) {
}
*/
/*
// Override to support conditional rearranging of the table view.
override func tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool {
// Return false if you do not want the item to be re-orderable.
return true
}
*/
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
Alamofire.request is async in nature. So when the table first loads, the request is still executing and your draftStandings doesn't have any data. When you rotate, the table is reloaded and by that time draftStandings does have some data already which the table shows.
Try adding a tableView.reloadData() after setting the draftStandings in the request response.

PFQuery first returning 6 items then 3 in a UITableViewController

He everyone,
Im pulling my hears out for a whole day for the following issue. My back-end is in Parse and i am doing a query on my table "events" in a UITableViewController. The problem is that the query returns the complete data in the ViewDidLoad but not in my tableView method. In my tableView im only getting 3 items returned. Im aware of that parse query doing a Asynchronously call but why its returning 3 items?
I would be gratefull if somebody can help me out here.
Here is my code:
class EventOverViewController: UITableViewController {
var events:Array = [AnyObject]();
var imageContainer : UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.separatorStyle = UITableViewCellSeparatorStyle.None;
self.retrieveInfoFromParse();
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Table view data source
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return self.events.count
}
func queryForTable() -> PFQuery {
let getEvents = PFQuery(className:"Event");
return getEvents;
}
func retrieveInfoFromParse(){
self.queryForTable().findObjectsInBackgroundWithBlock { (objects:[PFObject]?, error:NSError?) -> Void in
if error == nil {
for object in objects! {
self.events.append(object);
}
//RETURNING 6 ITEMS
print(self.events);
self.tableView.reloadData();
}
}
}
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return 230;
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("EventCell", forIndexPath:indexPath) as! EventTableViewCell
let eventData = self.events[indexPath.row];
//ONLY returning 3 ITEMS, WHY?
print(eventData);
return cell
}
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
let indexPath: NSIndexPath = self.tableView.indexPathForSelectedRow!
let destinationVC = segue.destinationViewController as! RootMainViewController
var secondEventData : Event!
secondEventData = self.events[indexPath.row] as! Event;
destinationVC.title = secondEventData.eventName;
destinationVC.event = secondEventData;
}
}

Resources