last day (14 days later) » 

10:31 AM
0
A: my protocol and delegates not working?

SMiIn CustomAddOnVC please write ItemTableViewCellObj.Itemdelegate = self in viewDidLoad or where ItemTableViewCell. in initialised . and also define delegate with weak reference weak var Itemdelegate: ItemDataDelegate?

 
when I create the weak reference it has error...
here what is ItemTableViewCellObj??
 
SMi
Does it work without weak reference?
You have CustomAddOnVC. And you use ItemTableViewCell here. Where do you initialize it?
 
i forget to set delegate for ItemDataDelegate in CustomAddOnVC class.. I am checking
 
SMi
Yes. that's what i want.
 
i have made some editing in my question in the 2nd part but still not working
 
SMi
10:31 AM
var ItemTableViewCellObj:ItemTableViewCell? this is wrong
As you are using ItemTableViewCell so you must use cellForRowAtIndexPath. right?
cells are initialised there
some thing like this?
let cell = tableView.dequeueReusableCellWithIdentifier("Item", forIndexPath: indexPath) as! ItemCell
here you need to set the delegate
 
yeah i have done this one .. but here how can i use the delegate property of ItemTableViewCell.. because both have no connection between them
see this
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

let cell:CustomOneCell = AddOnTableView.dequeueReusableCellWithIdentifier("addoncell") as! CustomOneCell


let item: AddOnItems = ADDONITEMS[indexPath.row]
cell.addOnName.text = item.name
cell.addOnPrice.text = "£\(item.price!)"
cell.addonitem_next = item.next!

//newly added for tick and untick
cell.checkboxOutlet.tag = indexPath.row
if (selectedItems.contains(indexPath.row)) {
cell.checkboxOutlet.setImage(UIImage(named:"checkboxredtick.png"), forState: .Normal)
 
SMi
Your delegate is of your cell right?
You define your protocol CustomOneCell on this class?
is it your ItemTableViewCell? where you define your protocol?
 
i define the protocol in Itemtableviewcell
 
SMi
Ok
let me clear
 
wait i will elaborate you my whole scenario
 
SMi
10:40 AM
ok
 
this is my custom table view custom cell in which items with buttons are theer
 
SMi
What is the name of this custom cell?
 
ItemTableViewcell, whre i defined the protocol
 
SMi
And what is the name of your viewcontroller where the table view exist?
 
menutableviewcontroller
here i took three labels of data
menu data , subcategory data , and item data
menu data i dispalyed in the header section
 
SMi
10:47 AM
so you should comform your delegate at menutableviewcontroller
and set delegate in this view controller cellforroaatindexpath method after initialising cell
 
after clicking the order button the item name , item price and item ID should sent to the next xib . for that purpose only i am creating the protocol to pass the data
 
SMi
then your next xib is a viewcontroller or UIView?
 
SMi
whatever? you should conform your code there
 
uiview
 
SMi
10:50 AM
and set delegate there
 
here in this view i need to fetch all data that i set as protocol
customAddonVc
 
SMi
do you debug ItemTableViewCellObj?.Itemdelegate = self ?
is it nil here ?
 

last day (14 days later) »