condition on segue identifier in protocol - ios

I have two view controllers 1st name is ViewController and 2nd Name is ContactVC. I have 3 buttons on 1st viewcontroller when i click on a button open 2nd viewController. In 2nd view controller i open phone contacts when i select any contact that contact name should be set as a button title. I have done with 1st button but from 2nd and 3rd button it does not works. Below is the code of 1st ViewController
import UIKit
import ContactsUI
class ViewController: UIViewController,CNContactPickerDelegate {
#IBOutlet weak var con1: UIButton!
#IBOutlet weak var con2: UIButton!
#IBOutlet weak var con3: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "Contact1Segue"
{
(segue.destination as! ContactVC).delegate = self
}
else if segue.identifier == "Contact2Segue"
{
(segue.destination as! ContactVC).delegate = self
}
else if segue.identifier == "Contact3Segue"
{
(segue.destination as! ContactVC).delegate = self
}
}
func findContacts() -> [CNContact]
{
let store = CNContactStore()
let keysToFetch = [CNContactFormatter.descriptorForRequiredKeys(for: .fullName),
CNContactImageDataKey,
CNContactPhoneNumbersKey] as [Any]
let fetchRequest = CNContactFetchRequest(keysToFetch: keysToFetch as! [CNKeyDescriptor])
var contacts = [CNContact]()
do {
try store.enumerateContacts(with: fetchRequest, usingBlock: { ( contact, stop) -> Void in
contacts.append(contact)
})
}
catch let error as NSError {
print(error.localizedDescription)
}
return contacts
}
func contactPickerDidCancel(picker: CNContactPickerViewController)
{
print("Cancel Contact Picker")
}
}
extension ViewController: ContactVCDelegate
{
func updateData(data: String)
{
self.con1.setTitle(data, for: .normal)
self.con2.setTitle(data, for: .normal)
self.con3.setTitle(data, for: .normal)
}
}
Below is the 2nd ViewController Code
import UIKit
import ContactsUI
class ContactVC: UIViewController, CNContactPickerDelegate, UITableViewDataSource, UITableViewDelegate {
var contacts = [CNContact]()
var Name:String?
var delegate: ContactVCDelegate?
#IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
DispatchQueue.global(qos: .background).async
{
let a = ViewController()
self.contacts = a.findContacts()
OperationQueue.main.addOperation
{
self.tableView!.reloadData()
}
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
print("Count:\(self.contacts.count)")
return self.contacts.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.row == 0
{
let cell = tableView.dequeueReusableCell(withIdentifier: "SearchRID", for: indexPath)
return cell
}
else
{
let cell = tableView.dequeueReusableCell(withIdentifier: "CellRID", for: indexPath)
let contact = contacts[indexPath.row] as CNContact
cell.textLabel!.text = "\(contact.givenName) \(contact.familyName)"
return cell
}
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
print("section:\(indexPath.section), row:\(indexPath.row)")
let allcontact = self.contacts[indexPath.row] as CNContact
Name = allcontact.givenName + allcontact.familyName
self.delegate?.updateData(data: Name!)
print("Name:\(Name)")
_ = self.navigationController?.popViewController(animated: true)
dismiss(animated: true, completion: nil)
}
//MARK:- CNContactPickerDelegate Method
func contactPicker(_ picker: CNContactPickerViewController, didSelect contacts: [CNContact]) {
contacts.forEach({contact in
for number in contact.phoneNumbers
{
let phonenum = number.value as CNPhoneNumber
print("NUmber is = \(phonenum)")
}
})
}
}
protocol ContactVCDelegate
{
func updateData(data: String)
}

Update your protocol:
protocol ContactVCDelegate
{
func updateData(buttonId:int, data: String)
}
Have a field in your second view controller with buttonId.
And set this value while preparing segue:
(segue.destination as! ContactVC).buttonId = 1
Your Update function:
func updateData(buttonId:int, data: String)
{
switch(buttonId){
case 1:
self.con1.setTitle(data, for: .normal)
break
case 2:
self.con2.setTitle(data, for: .normal)
break
case 3:
self.con3.setTitle(data, for: .normal)
break
}
}
In second view controller, onDidSelect:
self.delegate?.updateData(buttonId:buttonId,data: Name!)

Related

tableView reloadData doesn't work, delegate methods

I am trying to create new category in 1 view controller (AddCategoryViewController) and show it in table view controller (CategoryViewController). But there's an issue with reloading data.
New category item shows only after turning on and off the app, even when there is tableView.reloadData().
I tried to change the title of navigation in addButtonPressed function and the title changes immediately.
When I was using UIAlertView to add data, tableView.reloadData() worked. So I guess it's something with 2 view controllers and delegate methods?
Thanks for your help <3
show item:
import UIKit
import CoreData
class CategoryViewController: UITableViewController {
#IBOutlet weak var navigation: UINavigationItem!
var categoryArray = [Category]()
let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
override func viewDidLoad() {
super.viewDidLoad()
loadCategory()
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return categoryArray.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: .default, reuseIdentifier: "CategoryItemCell")
cell.textLabel?.text = categoryArray[indexPath.row].name
if let randomColor = categoryArray[indexPath.row].color {
cell.textLabel?.textColor = UIColor(hex: randomColor)
}
return cell
}
// MARK: - Table view data source
#IBAction func addPressed(_ sender: UIBarButtonItem) {
let addCategoryVC = storyboard?.instantiateViewController(withIdentifier: "AddCategoryViewController") as! AddCategoryViewController
addCategoryVC.delegate = self
present(addCategoryVC, animated: true, completion: nil)
}
// MARK: - CoreData methods
func saveCategory() {
do {
try context.save()
} catch {
print("Save error: \(error)")
}
tableView.reloadData()
}
func loadCategory(with request: NSFetchRequest<Category> = Category.fetchRequest()) {
do {
categoryArray = try context.fetch(request)
} catch {
print("Load error: \(error)")
}
tableView.reloadData()
}
func addCategory(name: String, description: String) {
let newCategory = Category(context: context.self)
newCategory.name = name
newCategory.descriptionOfCategory = description
newCategory.color = UIColor.random().toHex
saveCategory()
print("name form func: \(name)")
print("description from func: \(description)")
}
}
// MARK: AddCateogry delegate methods
extension CategoryViewController: AddCategoryDelegate {
func addButtonPressed(name: String, description: String) {
addCategory(name: name, description: description)
navigation.title = "I have changed!"
}
}
Add item:
import UIKit
protocol AddCategoryDelegate {
func addButtonPressed(name: String, description: String)
}
class AddCategoryViewController: UIViewController {
var delegate : AddCategoryDelegate!
#IBOutlet weak var nameTextField: UITextField!
#IBOutlet weak var descriptionTextField: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
#IBAction func addCategoryButtonPressed(_ sender: UIButton) {
delegate.addButtonPressed(name: nameTextField.text!, description: descriptionTextField.text!)
dismiss(animated: true, completion: nil)
}
}
You only save the category to coredata inside addCategory , but you have to add the item to the array also , or call loadCategory before tableView.reloadData() inside saveCategory

How do I get new items to display in List View

I am building an app in Xcode 9.4 and I am having trouble getting new items to display in a list view after creating it in another view controller. The item shows up in CoreData, but in order for the item to show in the list view I have to back out of the list view and then return to see it in the list.
I have added the Protocol and Delegate methods but something is still missing from the formula.
Here is the code from the DetailViewController where the new item is added:
import UIKit
import CoreData
protocol DetailViewControllerDelegate: class {
func detailViewController(_ controller: DetailViewController, didFinishAdding task: Task)
// func detailViewController(_ controller: DetailViewController, didFinishEditing task: Task)
}
class DetailViewController: UIViewController, UITextFieldDelegate, UITextViewDelegate {
var tasks = [Task]()
let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
var selectedTask: String?
var taskDetails: String?
var taskCategory: Category?
#IBOutlet weak var taskTitle: UITextField!
#IBOutlet weak var taskDetail: UITextView!
var taskToEdit: Task?
weak var delegate: DetailViewControllerDelegate? // Required to carry out the protocol methods
override func viewDidLoad() {
super.viewDidLoad()
taskTitle.text = selectedTask
taskDetail.text = taskDetails
taskDetail.textColor = UIColor.lightGray
navigationItem.largeTitleDisplayMode = .never
}
func textViewDidBeginEditing(_ textView: UITextView) {
if taskDetail.textColor == UIColor.lightGray {
taskDetail.text = nil
taskDetail.textColor = UIColor.black
}
}
func textViewDidEndEditing(_ textView: UITextView) {
if taskDetail.text.isEmpty {
taskDetail.text = "Details..."
taskDetail.textColor = UIColor.lightGray
}
}
override func viewWillAppear(_ animated: Bool) {
taskTitle.becomeFirstResponder()
}
#IBAction func doneButtonPressed(_ sender: UIBarButtonItem) {
let newTask = Task(context: self.context)
newTask.title = taskTitle.text!
newTask.details = taskDetail.text!
newTask.parentCategory = taskCategory!
delegate?.detailViewController(self, didFinishAdding: newTask)
// self.taskArray.append(newTask)
self.saveTasks()
navigationController?.popViewController(animated: true)
}
func saveTasks() {
do {
try context.save()
} catch {
print("Error saving context \(error)")
}
}
}
Here is the code from the List View controller, which should display the new item as soon as it is created:
import UIKit
import CoreData
class TaskListTableViewController: UITableViewController, DetailViewControllerDelegate {
var tasks = [Task]()
var selectedCategory: Category? {
didSet {
loadTasks()
}
}
let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
override func viewDidLoad() {
super.viewDidLoad()
navigationItem.largeTitleDisplayMode = .never
title = selectedCategory?.name
loadTasks()
tableView.reloadData()
// self.navigationItem.rightBarButtonItem = self.editButtonItem
}
func detailViewController(_ controller: DetailViewController, didFinishAdding task: Task) {
let newRowIndex = tasks.count
tasks.append(task)
let indexPath = IndexPath(row: newRowIndex, section: 0)
let indexPaths = [indexPath]
tableView.insertRows(at: indexPaths, with: .automatic)
tableView.reloadData()
navigationController?.popViewController(animated: true)
}
// TODO: finish this
func detailViewController(_ controller: DetailViewController, didFinishEditing task: Task) {
}
// MARK: - Table view data source
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return tasks.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "TaskCell", for: indexPath)
let task = tasks[indexPath.row]
let label = cell.viewWithTag(1001) as! UILabel
label.text = task.title
return cell
}
// MARK: - Navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "AddItem" {
let destinationVC = segue.destination as! DetailViewController
destinationVC.taskCategory = selectedCategory
} else if segue.identifier == "EditItem" {
let destinationVC = segue.destination as! DetailViewController
destinationVC.taskCategory = selectedCategory
let indexPath = tableView.indexPathForSelectedRow!
let task = tasks[indexPath.row]
destinationVC.selectedTask = task.title
destinationVC.taskDetails = task.details
}
}
func loadTasks(with request: NSFetchRequest<Task> = Task.fetchRequest(), predicate: NSPredicate? = nil) {
let categoryPredicate = NSPredicate(format: "parentCategory.name MATCHES %#", selectedCategory!.name!)
request.predicate = categoryPredicate
do {
tasks = try context.fetch(request)
} catch {
print("Error fetching data \(error)")
}
tableView.reloadData()
}
#IBAction func addTaskButton(_ sender: UIBarButtonItem) {
print("new task added")
}
}
You need to set the delegate in prepareForSegue
destinationVC.delegate = self

Swift: Show data from tableView to another ViewController (JSON, Alamorife, AlamofireImage)

I'm trying to do an app in which the data were obtained from JSON.
In the picture below you can see the project:
Project
If we click on the photo opens the details page. The problem is because I do not know how to pick up the data shown in the details page. Please help me.
Here is the code
import UIKit
import Alamofire
import AlamofireImage
import SwiftyJSON
class ViewController: UIViewController ,UITableViewDelegate,UITableViewDataSource,UISearchBarDelegate {
#IBOutlet weak var searchbarValue: UISearchBar!
weak open var delegate: UISearchBarDelegate?
#IBOutlet weak var tableView: UITableView!
var albumArray = [AnyObject]()
var url = ("https://jsonplaceholder.typicode.com/photos")
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.searchbarValue?.delegate = self
Alamofire.request("https://jsonplaceholder.typicode.com/photos").responseJSON { (responseData) -> Void in
if((responseData.result.value) != nil) {
let swiftyJsonVar = JSON(responseData.result.value!)
if let resData = swiftyJsonVar[].arrayObject {
self.albumArray = resData as [AnyObject]; ()
}
if self.albumArray.count > 0 {
self.tableView.reloadData()
}
}
}
}
public func searchBarTextDidEndEditing(_ searchBar: UISearchBar) // called when text ends editing
{
callAlamo(searchTerm: searchbarValue.text!)
}
func callAlamo(searchTerm: String)
{
Alamofire.request("https://jsonplaceholder.typicode.com/photos").responseJSON { (responseData) -> Void in
if((responseData.result.value) != nil) {
let swiftyJsonVar = JSON(responseData.result.value!)
if let resData = swiftyJsonVar[].arrayObject {
self.albumArray = resData as [AnyObject]; ()
}
if self.albumArray.count > 0 {
self.tableView.reloadData()
}
}
}
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return albumArray.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as? CostumTableViewCell
let title = albumArray[indexPath.row]
cell?.titleLabel?.text = title["title"] as? String
//cell?.url?.image = UIImage(data: title as! Data)
let imageUrl = title["thumbnailUrl"] as? String
//print(imageUrl)
let urlRequest = URLRequest(url: URL(string: imageUrl!)!)
Alamofire.request(urlRequest).responseImage { response in
if let image = response.result.value {
// print("image downloaded: \(title["url"])")
cell?.url?.image = image
}
}
return cell!
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
performSegue(withIdentifier: "showDetails", sender: self)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let indexPath = self.tableView.indexPathForSelectedRow?.row
let vc = segue.destination as! DetailsViewController
//here should be the code
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Also you can see the DetailsViewController code:
import UIKit
class DetailsViewController: UIViewController {
var image2 = UIImage()
var title2 = String()
#IBOutlet var mainImageView: UIImageView!
#IBOutlet var songTitle: UILabel!
override func viewDidLoad() {
songTitle.text = title2
mainImageView.image = image2
}
}
You can easily pass value from tableview to detail view using the below code :
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let indexPath = self.tableView.indexPathForSelectedRow
let cell : CostumTableViewCell = self.tableView.cellForRow(at: indexPath!) as! CostumTableViewCell
let vc = segue.destination as! DetailsViewController
vc.image2 = cell.url.image!
vc.title2 = cell.titleLabel.text!
}
class ViewController: UIViewController ,UITableViewDelegate,UITableViewDataSource,UISearchBarDelegate {
var customArr = [CustomElement]()
var arr = [Any]()
// In viewDidLoad , you can append element to customArr
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
var image = customArr[indexpath.row].image
var title = customArr[indexpath.row].title
arr.append(image)
arr.append(title)
performSegue(withIdentifier: "showDetails", sender: arr)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let indexPath = self.tableView.indexPathForSelectedRow?.row
if segue.identifier = "showDetails" {
if let vc = segue.destination as! DetailsViewController {
vc.arr = sender
}
}
//here should be the code
}
}
class DetailsViewController: UIViewController {
var arr = [Any]()
}

Delegate between controllers doesn't work. Why?

I try to use delegate to send data from textField which is in the Detail2(ViewController) to array which is in the ViewController.
I used here print method and first print show that one element has been added to the array but the second print method which is below the ViewVillAppear() show that array is empty. How? I want to be able to to use delegate to add data to my table.
["sdsd"] First print from the console
[]Second print from the console
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
#IBOutlet var add: UIBarButtonItem!
#IBOutlet var tv: UITableView!
var array :[String] = []
override func viewDidLoad() {
super.viewDidLoad()
tv.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "segue" {
let vc: Detail2 = segue.destination as! Detail2
vc.delegate = self
}
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return array.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
cell.textLabel?.text = array[indexPath.row]
return cell
}
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
array.remove(at: indexPath.row )
tv.reloadData()
}
}
func alert () {
}
override func viewWillAppear(_ animated: Bool) {
tv.reloadData()
print(array)
}
}
extension ViewController: Data {
func tekst(data: String) {
array.append(data)
print(array)
}
}
and Detail2
protocol Data {
func tekst (data: String)
}
class Detail2: UIViewController {
var delegate: Data? = nil
#IBAction func btn(_ sender: Any) {
let sb = storyboard?.instantiateViewController(withIdentifier: "Main" ) as! ViewController
navigationController?.pushViewController(sb, animated: true)
if delegate != nil {
if txtfield.text != nil {
let napis = txtfield.text
delegate?.tekst(data: napis!)
}
}
}
#IBOutlet var btn: UIButton!
#IBOutlet var txtfield: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
btn.backgroundColor = UIColor.blue
btn.tintColor = UIColor.white
btn.layer.cornerRadius = 25
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Just update your function with:
#IBAction func btn(_ sender: Any) {
if delegate != nil {
if txtfield.text != nil {
let napis = txtfield.text
delegate?.tekst(data: napis!)
}
navigationController?.popViewController(animated: true)
}
}
Update:
extension ViewController: Data {
func tekst(data: String) {
array.append(data)
print(array)
self.tv.reloadData()
}
}
You need to add this delegate?.tekst(data: napis!) inside completion handler, because you are using navigationController, there is no option for completion handler,So have to add UINavigationController extension like that:
extension UINavigationController {
public func pushViewController(viewController: UIViewController,
animated: Bool,
completion: (() -> Void)?) {
CATransaction.begin()
CATransaction.setCompletionBlock(completion)
pushViewController(viewController, animated: animated)
CATransaction.commit()
}
}
change this
navigationController?.pushViewController(sb, animated: true){
if delegate != nil {
if txtfield.text != nil {
let napis = txtfield.text
delegate?.tekst(data: napis!)
}
Update your code in Detail2 viewcontroller
#IBAction func btn(_ sender: Any) {
if delegate != nil {
if txtfield.text != nil {
let napis = txtfield.text
delegate?.tekst(data: napis!)
}
}
navigationController?.popViewController(animated: true)
}
In the ViewController implement the delegate method
func tekst (data: String) {
array.append(data)
}
// in detail
#IBAction func btn(_ sender: Any) {
if txtfield.text != nil {
let napis = txtfield.text
delegate?.tekst(data: napis!)
}
/// dismiss detail here don't push main again
self.navigationController?.popViewController(animated: true)
}

How do I pass the same textview, button, and label after clicking the Cell swift?

I would like to make it so that when the user clicks on the cell, it shows exactly everything in the cell. TextView, Buttons, and label. How can I do this?
Here is the code:
TableCell:
import UIKit
class TableViewCell: UITableViewCell {
#IBOutlet weak var textView: UITextView!
#IBAction func 1Button(sender: AnyObject) {
}
#IBAction func 2Button(sender: AnyObject) {
}
#IBOutlet weak var counter: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
TableViewController:
import UIKit
let reuseIdentifier = "Cell"
class UserFeedTableViewController: UITableViewController, ComposeViewControllerDelegate {
private var posts: [PFObject]? {
didSet {
tableView.reloadData()
}
}
override func viewDidLoad() {
super.viewDidLoad()
Downloader.sharedDownloader.queryForPosts()
NSNotificationCenter.defaultCenter().addObserver(self, selector: "queryFeeds:", name: queryNotification, object: nil)
}
// Notification SEL
func queryFeeds(notification: NSNotification) {
posts = notification.object as? [PFObject]
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "postSegue" {
let nav = segue.destinationViewController as! UINavigationController
let composeVc = nav.topViewController as! ComposeViewController
composeVc.delegate = self
}
if segue.identifier == "commentsSegue" {
let vc = segue.destinationViewController as! CommentsViewController
let cell = sender as! UITableViewCell
let indexPath = tableView.indexPathForCell(cell)
let object = posts![indexPath!.row]
vc.postObject = object
}
}
//dismiss compose vc
func dismissComposeViewController(ViewController: ComposeViewController) {
dismissViewControllerAnimated(true, completion: nil)
}
func reloadTableViewAfterPosting() {
dismissViewControllerAnimated(true, completion: nil)
Downloader.sharedDownloader.queryForPosts()
}
}
extension ViewController {
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete method implementation.
// Return the number of rows in the section.
return posts?.count ?? 0
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier(reuseIdentifier, forIndexPath: indexPath) as! UserFeedTableViewCell
// Configure the cell...
if let posts = posts {
let object = posts[indexPath.row]
cell.textView?.text = object["post"] as? String
}
return cell
}

Resources