I’ve been trying to have two tables in a utility application but I’m having problems; when I create two delegates and two data sources I’m getting an error. Is there a way to make multiple delegates in one class?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Actually you cannot put two delegates and two datsource for two tables in same view controller.
You can use a flag or a hidden UILabel where in you set the unique value and access datasource and delegates based on the value of flag or label.
For Example:
If I have 2 tables, one for Buy and one for Sale
I will set UILabel named say tableIdentifier
when I want to load the Buy table
and similarly set
when I want to load the Sale table
Now as far as datasource and delegate methods are concerned, this is how it goes:
Similarly it works for each of the delegate and datasource methods based on the value of label or flag.
Note:
If you use a label as I have shown above then you need to
outletthat label to a hidden label in XIB and@synthesizethe label, otherwise its value will return null in the case if the value is not retained.Hope this helps you
EDIT:
In that case you can take the count as
[plist1Array count] + [plist2Array count]innumberOfRowsInSection:methodIn
cellForRowAtIndexPath:method you can check for indexPath.row and load data based on thatEDIT-1:
If you want you can just show them in different sections of the same table rather than showing them in two different tables like
In
numberOfRowsInSection:methodAnd in
cellForRowAtIndexPath:methodHope this helps