How To get values of textfields from a UITableViewCell? - swift

So I have thisUITableView cell that has 4 UITextField, and I want to get their values on button click.
This code does not retrieve any values.
#IBAction func printBtnAction(_ sender: Any) {
let cell = self.myTableView.dequeueReusableCell(withIdentifier: "manualAddC1") as! AddFriendC1Cell
let alias = cell.aliasTextField.text!
let primaryPhone = cell.primaryPhoneTextField.text!
let secondaryPhone = cell.seondaryPhoneTextField.text!
let email = cell.emailAddressTextField.text!
print("Alias: \(alias), Phone: \(primaryPhone), Phone2: \(secondaryPhone), Email: \(email)")
}
This is the screenshot of the TableView

I finally figured it out with this simple solution.
#IBAction func saveBtnAction(_ sender: Any) {
let index = IndexPath(row: 0, section: 0)
let cell: AddFriendC1Cell = self.myTableView.cellForRow(at: index) as! AddFriendC1Cell
self.alias = cell.aliasTextField.text!
self.primaryPhone = cell.primaryPhoneTextField.text!
self.secondaryPhone = cell.seondaryPhoneTextField.text!
self.email = cell.emailAddressTextField.text!
print("Alias: \(self.alias), Phone: \(self.primaryPhone), Phone2: \(self.secondaryPhone), Email: \(self.email)")
}

OK. You are dequeueing a tableViewCell when you press on a button.
let cell = self.myTableView.dequeueReusableCell(withIdentifier: "manualAddC1") as! AddFriendC1Cell
I believe that you want to get a reference to an existing tableViewCell like this:
if let cell = tableView.cellForRow(at: indexPath) as? AddFriendC1Cell {
// do what you need with cell
}
Even though this would work, I wouldn't suggest this approach. What if user is using a smaller-screen phone like iPhone 4 and some cells are not visible on the screen? I think that in that case tableView.cellForRow would return nil for non-visible cell.
I would suggest implementing textField:shouldChange in each cell with text field with a delegate to the tableView's viewController. When text is changed in the cell, delegate should propagate the change to the viewController which would save the value in an instance variable.
Then, when you press on the button, you would simply take values from instance variables.

// 1st step
In UITableViewCell
import UIKit
#objc protocol TableViewDelegate: NSObjectProtocol{
func afterClickingReturnInTextField(cell: ThirdTableCell)
}
class TableViewCell: UITableViewCell, UITextFieldDelegate {
#IBOutlet weak var enterTextField: UITextField!
weak var tableViewDelegate: TableViewDelegate?
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
enterTextField.delegate = self
}
// #IBAction Of UITextfiled
#IBAction func tapHerre(_ sender: UITextField) {
tableViewDelegate?.responds(to: #selector(TableViewDelegate.afterClickingReturnInTextField(cell:)))
tableViewDelegate?.afterClickingReturnInTextField(cell: self)
}
// UITextField Defaults delegates
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
enterTextField.resignFirstResponder()
return true
}
func textFieldDidEndEditing(_ textField: UITextField) {
enterTextField = textField
}
}
// 2nd step
In UITableViewCell
extension ViewController: UITableViewDelegate, UITableViewDataSource, TableViewDelegate {
var valueToPass : String?
func afterClickingReturnInTextField(cell: ThirdTableCell) {
valueToPass = cell.enterTextField.text
}
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return youArray.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableview.dequeueReusableCell(withIdentifier: "TableViewCell") as! TableViewCell
cell.enterTextField.text = youArray[indexPath.row]
cell.tableViewDelegate = (self as TableViewDelegate)
return cell
}
}
When the keyboard disappears you can find TextField value in valueToPass

I suppose your tableViewCells are not dynamic.
Your cell method will looks like this.
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "YourCellID") as! YourClass
cell.yourTextField.tag = indexPath.row
//
// Alias will be tag 0
// Primary Phone will be tag 1
// Secondary Phone will be tag 2
// Email Address will be tag 3, so on and so forth
// Then, attach to each delegate
//
cell.yourTextField.delegate = self
}
Inside your UITableView handling class (which conforms to UITextFieldDelegate protocol), write this.
func textField(_ textField: UITextField, shouldChangeCharactersIn range:NSRange, replacementString string: String) -> Bool {
let kActualText = (textField.text ?? "") + string
switch textField.tag
{
case 0:
aliasValueHolder = kActualText;
case 1:
primaryPhoneValueHolder = kActualText;
case 2:
secondaryPhoneValueHolder = kActualText;
case 3:
emailAddressValueHolder = kActualText;
default:
print("It is nothing");
}
return true;
}
Then you can submit it.

func textField(_ textField: UITextField, shouldChangeCharactersIn range:NSRange, replacementString string: String) -> Bool {
// let kActualText = (textField.text ?? "") + string
var kActualText = (textField.text! as NSString).replacingCharacters(in: range, with: string)
kActualText = kActualText.trimmingCharacters(in: .whitespaces)
if textField.tag == 0
{
email_address = kActualText;
}
else if textField.tag == 3
{
password = kActualText;
}
else
{
print("It is nothing")
}
return true;
}

In my opinion, you should implement TextField delegates methods in the tableCell class and manage all the validations and input text in tableCell class.
Now, you will need to fetch all entered values, for this, you have to use Protocol in tableCell class and send entered value using the delegate to viewController also with the tag to identify that which value has entered like the Phone number or email.
Using this way, your code will be reduced and structured.
Happy Coding !!

Related

How to maintain state of switch button inside tableviewcell with searchbar in xcode

Description : i have a content in tableview along with switch button .
Problem : after using the searchbar for serching items in tableview state of switch button is lost - switch button which was set on for row 0 and row 1 has lost .
To achieve this you have to store button state with your data.
And Read the data in cellForRowAtIndexPath: Handle UI
Example:
if indexPath.row == 0 || indexPath.row == 1{
// Handle Button UI here
let value = buttonArrayData[indexPath.row]
if(value){
//button selected
//update buttonArrayData data accordingly.
}
else{
//button unselected
//update buttonArrayData data accordingly.
}
}
It is not a problem associated with UISearchBar but seems because of TableView reload.
To save the state of UISwitch in the case of table reload, you need have a custom UITableViewCell class and UISwitch outlet inside it.
Then to save a UISwitch state for further use
You can store only the selected cell index as state in UserDefault and check the same against the current index in cellForRowAt tableView method. If it is found then your last state is ON otherwise default one is OFF.
This code snippet will work as you expect:
Custom UITableViewCell class
class CustomCell: UITableViewCell {
#IBOutlet weak var switchObj: UISwitch!
#IBOutlet weak var textValue: UILabel!
#IBAction func toggleState(_ sender: Any) {
var loadValues: [Int: Bool]!
if let values = Memory.getStatesFromMemory() {
loadValues = values
} else {
loadValues = [Int: Bool]()
}
loadValues[switchObj.tag] = switchObj.isOn
Memory.saveSwitchStatesToMemory(savedStates: loadValues)
}
}
UIViewController class
class CustomTableView: UIViewController, UITableViewDelegate, UITableViewDataSource {
var savedStates: [Int: Bool]!
override func viewDidLoad(){
super.viewDidLoad()
if let values = Memory.getStatesFromMemory() {
savedStates = values
} else {
savedStates = [Int: Bool]()
}
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 10
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "CustomCell") as? CustomCell
cell?.switchObj.isOn = savedStates[indexPath.row] == nil ? false : savedStates[indexPath.row]!
cell?.switchObj.tag = indexPath.row
cell?.textValue.text = "Switch stored state >>"
return cell!
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 80
}
}
Custom class to use for save/retrieve values from memory
class Memory {
static func getStatesFromMemory() -> [Int: Bool]? {
if let switchValues = UserDefaults.standard.object(forKey: "SwitchStates") as? Data {
let decodedTeams = NSKeyedUnarchiver.unarchiveObject(with: switchValues) as! [Int: Bool]
return decodedTeams
}
return nil
}
static func saveSwitchStatesToMemory(savedStates: [Int: Bool]) {
let encodedData = NSKeyedArchiver.archivedData(withRootObject: savedStates)
let userDefaults = UserDefaults.standard
userDefaults.set(encodedData, forKey: "SwitchStates")
UserDefaults.standard.synchronize()
}
}

How to move curser from one textfield to another in a tableview Form in iOS?

I have a Form that is to be made using a tableview. Each cell have a textfield and I want my cursor to move into next textfield when I tap "next" in keyboard.
here is the tableview code I m using currently:
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.arrayData.count;
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tblView.dequeueReusableCell(withIdentifier: "cellTextField")! as! cellTextField
cell.tfValue.placeholder = objclsSignup.placeHolder! as String
cell.tfValue.tag = indexPath.row
cell.tfValue.delegate = self
cell.tfValue.returnKeyType = UIReturnKeyType.next
if indexPath.row == 6 {
cell.tfValue.returnKeyType = UIReturnKeyType.done
}
return cell
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
if textField.returnKeyType == UIReturnKeyType.next{
textField.becomeFirstResponder()
}else {
textField.resignFirstResponder()
}
return true
}
I am using swift 4, Xcode 10.2.
First, instead of passing data with tags, use delegates in the cell like described here.
When you have a delegate that passes the cell up to your data source/delegate, use the indexPath to grab the next cell (if any) and use the function becomeFirstResponder()on your UITextField to focus it.
Try this code set delegate to textField in Storyboard..
extension LoginPageViewController: UITextFieldDelegate {
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
if textField == userNameTextField {
userNameTextField.resignFirstResponder()
emailTextField.becomeFirstResponder()
} else if textField == emailTextField {
emailTextField.resignFirstResponder()
passwordTextField.becomeFirstResponder()
} else {
performYourAction()
}
return true
}

TableViewController issue: won't save user input from textView

Update:
so goal of this to save the text that user enters in a UITextView in cell, so that the text is saved for that particular cell number and does not duplicate, move or remove the text.
as suggested I am trying to handle the textViewdidChange func inside of the custom cell, by doing the following:
var onTextEntered: ((String?) -> ())!
func setup() {
notesTextView.delegate = self
}
func textViewDidChange(_ textView: UITextView) {
onTextEntered(notesTextView.text)
}
making a string that holds the text and then adding the text to the String every time textViewDidChange is called (trying to explain this to myself as we go along, so please correct me if my explanation needs it).
next in CellForRowAt
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cellIdentifier = "TableViewNotesCell"
let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) as! TableViewNotesCell
cell.setup()
cell.onTextEntered = {input in
if let text = input {
self.cellText[indexPath.row] = text // here is the error (index out of range)
}
if indexPath.row < self.cellText.count {
cell.notesTextView.text = self.cellText[indexPath.row] ?? "placeholder"
}
}
return cell
}
when I do the above code, as soon as textViewDidChange is called (when i type a single letter or digit in textView) the I get the error : "Fatal error: Index out of range" on the line which I use the array of cellText[indexPath.row] = text. please help or let me know if my understanding of the process is wrong would love to learn!
You can try to save for every single edit
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// inside cellForRowAt
cell.textView.delegate = self
cell.textView.tag = indexPath.row
return cell
}
#objc func textViewDidChange(_ tex: UITextView) {
cellEndEdit[tex.tag] = tex.text!
}
class VC:UIViewController,UITextViewDelegate {
give default values for the array
var cellEndEdit = [String](repeating: "", count: numberOfRows)
Assuming, that you tableView has a variable number of cells, and all of them have a UITextView, whose content should be recorded and indexed, I would recommend to create a custom UITableViewCell, that handles the textView itself.
class CustomTableViewCell: UITableViewCell, UITextViewDelegate {
#IBOutlet weak var textView: UITextView()
var onTextEntered: ((String?) -> ()) //that's a callback
func setup() {
textView.delegate = self
}
override func textViewDidChange(textView: UITextView) {
onTextEntered(textView.text)
}
}
Since you're working with a sorted list of user inputs, you should have your array at hands, in which you can store and from which you can retrieve data. So if some data already exists, grep through your array and fill the cells that deserve it. Also define the onTextEntered callback here to tell the cell what to do, if it gets called (in your case, store the text of the UITextView in your array).
//your carrier, if you store the already existing user inputs some where, map them in here
//depending on how you calculate the number of cells, this array has to have the same size so use the same logic for this
var yourStringCarrierArray: [String?] = []
override func tableView(_ tableview: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "YourTableViewCell", for: indexPath) as! CustomTableViewCell
cell.setup()
cell.onTextEntered = { input in
if let text = input {
self.yourStringCarrierArray[indexPath.row] = text
}
if indexPath.row < yourStringCarrierArray.count {
cell.textView.text = yourStringCarrierArray[indexPath.row] ?? "placeholder string, because there's no input here so far"
}
}
I hope this will help or at least give you a new perspective, it has been a while, i coded in Swift. Feel free to ask me, if something is unclear.
Use an object to save the string value, since String in swift is value type. Here is an example:
class TestViewController: UIViewController {
#IBOutlet weak var tableView: UITableView!
var dataArray: [CellData] = []
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
tableView.delegate = self
tableView.dataSource = self
for _ in 0..<20 {
dataArray.append(CellData())
}
}
}
extension TestViewController: UITableViewDelegate, UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 20
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "TestTableViewCell", for: indexPath) as! TestTableViewCell
cell.setData(data: dataArray[indexPath.row])
return cell
}
}
class TestTableViewCell: UITableViewCell {
#IBOutlet weak var textView: UITextView!
var data: CellData!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
textView.text = ""
textView.delegate = self
}
func setData(data: CellData) -> Void {
self.data = data
self.textView.text = data.stringValue
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
extension TestTableViewCell: UITextViewDelegate {
func textViewDidChange(_ textView: UITextView) {
self.data.stringValue = textView.text
}
}
class CellData {
var stringValue: String = ""
}

UITableViewCell with Save button. textField and a label

i want create in swift a tableView with 2 prototype cells, in one cell i've a label and a text field, in other cell i've a save button, the #IBOutlet and #IBAction are in a separated UITableViewCell file, i want write something in Text Field and when click the save button, must change the label.text with textField.text, but i've an issue, when i click the button the value of textField is nil. I'm now in swift, how can resolve this issue?
Thanks
I've resolved the issue with the tag
cell.propertyName.tag = indexPath.row
and this delegate
func textField(textField: UITextField, shouldChangeCharactersInRange range:NSRange, replacementString string: String) -> Bool {
if textField.tag == 0 {
CoreDataController.sharedIstanceCData.matsDataField = "" + textField.text!+string
} else {
CoreDataController.sharedIstanceCData.commentDataField = "" + textField.text!+string
}
return true
}
it resolve my problem, tnx all
The scenario is this in pic
have two files, TableViewController.swift with this inside
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 {
return 2
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
if indexPath.row == 0 {
let cell = tableView.dequeueReusableCellWithIdentifier("cella", forIndexPath: indexPath) as! TableViewCell
return cell
}
let cell = tableView.dequeueReusableCellWithIdentifier("saveCell", forIndexPath: indexPath) as! TableViewCell
return cell
}
and second file named TableViewCell.swift
import UIKit
class TableViewCell: UITableViewCell {
#IBOutlet weak var textField: UITextField!
#IBOutlet weak var label: 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
}
#IBAction func saveBtn(sender: AnyObject) {
self.label.text = textField.text
}
}

Saving values to UserDefults from Textfield in TableView : Swift

I am trying to save values from a tableview that users will input into the textfield, the problem is that I do not know how to access the new value and replace the string in the array.
So basically the app will display fields based on what the user wants and then the user can edit those values to their liking. Once the textfields have been updated, the values are stored again in userdefaults so that the next time the tableview is opened, the update values will appear.
This is what the tableviewcontroller looks like at the moment:
//
// Asset1TableViewController.swift
// Net Calc 2
//
// Created by Joshua Peterson on 30/06/2015.
// Copyright © 2015 Peterson Productions. All rights reserved.
//
import UIKit
class Asset1TableViewController: UITableViewController {
var dataHolder: [NSString] = [NSString]()
var finalDataHolder: [NSString] = [NSString]()
var acountAmountHolder: [NSString] = [NSString]()
var finalAccountAmountHolder: [NSString] = [NSString]()
let defaults = NSUserDefaults.standardUserDefaults()
let key1 = "keySave1"
let key2 = "keySave2"
override func viewDidLoad() {
super.viewDidLoad()
dispatch_async(dispatch_get_main_queue(), { () -> Void in
if let storedTitleValue : NSArray? = self.defaults.arrayForKey(self.key1) {
if storedTitleValue == nil {
self.dataHolder = [NSString]()
} else {
let readArray : [NSString] = storedTitleValue as! [NSString]
for element in readArray {
self.dataHolder.append(element as String)
self.finalDataHolder.append(element as String)
}
}
}
if let storedAmountValue : NSArray? = self.defaults.arrayForKey(self.key2) {
if storedAmountValue == nil {
self.acountAmountHolder = [NSString]()
} else {
let readArray : [NSString] = storedAmountValue as! [NSString]
for element in readArray {
self.acountAmountHolder.append(element as String)
self.finalAccountAmountHolder.append(element as String)
}
}
}
})
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
// MARK: - Table view data source
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return dataHolder.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Account1Cell", forIndexPath: indexPath) as! Account1Cell
cell.AccountLabel.text = dataHolder[indexPath.row] as String
cell.AccountAmount.text = acountAmountHolder[indexPath.row] as String
return cell
}
#IBAction func addButtonTapped(sender: AnyObject) {
let newAccounTitle = "Account Name"
let newAccountAmount = "R0.00"
dataHolder.append(newAccounTitle)
acountAmountHolder.append(newAccountAmount)
tableView.reloadData()
}
#IBAction func saveButtonTapped(sender: AnyObject) {
// Save
defaults.setObject(dataHolder as Array, forKey: key1)
defaults.setObject(acountAmountHolder as Array, forKey: key2)
defaults.synchronize()
}
override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
return true
}
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
if editingStyle == UITableViewCellEditingStyle.Delete {
dataHolder.removeAtIndex(indexPath.row)
acountAmountHolder.removeAtIndex(indexPath.row)
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Automatic)
}
}
/*
// 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 NO if you do not want the item to be re-orderable.
return true
}
*/
}
I have tried to apply some of the code that i have found on the website but the problem is that I cant actually connect to the cell.
Ok so after some research I have added a few functions to the custom cell class so that it looks like this:
import UIKit
protocol TableViewCellDelegate {
// Indicates that the edit process has begun for the given cell
func cellDidBeginEditing(editingCell: Account1Cell)
// Indicates that the edit process has committed for the given cell
func cellDidEndEditing(editingCell: Account1Cell)
}
class Account1Cell: UITableViewCell, UITextFieldDelegate {
#IBOutlet weak var AccountLabel: UITextField!
#IBOutlet weak var AccountAmount: UITextField!
var delegate: TableViewCellDelegate?
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
AccountLabel.delegate = self
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
func textFieldShouldReturn(textField: UITextField) -> Bool {
// close the keyboard on Enter
AccountLabel.resignFirstResponder()
return false
}
func textFieldShouldBeginEditing(textField: UITextField) -> Bool {
// disable editing of completed to-do items
return true
}
func textFieldDidEndEditing(textField: UITextField) {
if AccountLabel != nil {
let newAccountLabel = AccountLabel.text
print(newAccountLabel) // Prints out the new edited text!!!!!!!!
}
if delegate != nil {
delegate!.cellDidEndEditing(self)
}
}
func textFieldDidBeginEditing(textField: UITextField) {
if delegate != nil {
delegate!.cellDidBeginEditing(self)
}
}
}
Now what I need to do is either replace that value in the Array at the index (which i think is going to be rather complicated) or create some sort of loop that will read ALL the values and simply store all of the new values to UserDefaults. Maybe there is something else?
Any help is appreciated!!
You should have a protocol in your custom cell like this, and call it when the text field in the cell gets modified:
protocol TableViewCellToTVController{
func cellCurrentlyEditing(editingCell: Account1Cell) -> Int
}
....
func textFieldShouldReturn(textField: UITextField) -> Bool {
// close the keyboard on Enter
let myrow: Int? = self.delegate_special?.cellCurrentlyEditing(self)
println("cellCurrentlyEditing got called from delegate" , myrow)
AccountLabel.resignFirstResponder()
return false
}
implement this function in tableviewcontroller to know which row got selected :
func cellCurrentlyEditing(editingCell: Account1Cell) -> Int{
var rowNum = 0
let indexP: NSIndexPath = tableView.indexPathForCell(editingCell)!
rowNum = indexP.row
return rowNum
}
also make your tableviewcontroller the delegate for each cell:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Account1Cell", forIndexPath: indexPath) as! Account1Cell
cell.AccountLabel.text = dataHolder[indexPath.row] as String
cell.AccountAmount.text = acountAmountHolder[indexPath.row] as String
cell.delegate_special = self;
return cell
}