last day (15 days later) » 

7:53 AM
1
A: Table view cell not able to get in numberOfRowsInSection

Syed Qamar AbbasYou are using a wrong approach in your numberOfRows method. Your cell load after this method numberOfRows. Current cell does not have list. So in this method first get the listObject and then return its count. Try to use below approach.. func tableView(_ tableView: UITableView, numberOfRowsInSec...

 
In my vc i declared initaially lazy var List: [[String: Any]]? = FetchInfoUtil.sharedInstance.List
But how can i use my table view cell label on outside of the delegate methods ?
 
Why do you want to use cell label outside the delegate method?
 
but ist getting crash on some places
Thread 1: Fatal error: Index out of range
i needs to pass the index value..or bec i have a pagemenu controller at top. On click any menu name, i have to show one table view at bottom under each menu items. Now i am passing the index value click on menu items..based on that ia m showing data
 
I have update the answer. Your methods name was incorrect.
Can you display what exactly UI you want to draw?
 
based on the menu click i am passing the index value in notification center and passing the values to the table view controller. And from there through the index value i am passing the index .row value and i am getting
 
7:53 AM
Do you have multiple Arrays? Like one array for upper menu and one array for lower TableView?
 
those menu ara hardcode ..below table view data is list with having more data
 
Got your point. I have made changes in my methods and updated the answer as per your need. Please have a look.
 
then in cell for row at index path method..should i needs to use like ur answer or like my question post ?
 
Both are same. All you have to be careful about is return the accurate count in the numberOfRows.
In number of rows first you have to get the list of selectedIndex and then return the related count.
 
not getting ur last point
 
7:53 AM
List is array which hold dictionaries for your above menus. If your selected Menu index is 1. Just save this index and then in cellForRow method first get dictionary of this selected menu index from the List not from the cell because cell is not loaded yet. After getting the dictionary of your selected index just fetch list object from inside and return the count. All else of your previous code looks good.
 
i tried now for particular 2 index i am getting crash
 
Which solution have you tried? Entirely mine? or Entirely your? or Half Mine/Half Yours.?
Lets have a chat here.
 
Hi
 
Which solution have you tried?
 
i tried with current index only..bec that code for me to understand clearly about ir
it
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
guard let gamesList = skillList?[section]["games_list"] as? [[String: Any]] else {
return 0
}
return gamesList.count;
}
 
7:54 AM
You are doing wrong.
 
but other index r working fine...only 2 index r getting the crashes
 
guard let gamesList = skillList?[section]["games_list"]
Look at this line. You are using skillList?[section] instead of section fetch from your selectedIndex. Use that `Int` variable in which you are storing your selectedMenuIndex.
Also show me the code of your cellForRow method.
 
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

let cell = tableView.dequeueReusableCell(withIdentifier: "KMStatsTableViewCell", for: indexPath) as! KMStatsTableViewCell
print(indexPath.row)

switch CurrentIndexVal {
case 1: // focus
cell.skillInfo = skillList?[0];
cell.gameImage.tintColor = Utils.colorCode.focus_primary
cell.gameScore.textColor = Utils.colorCode.focus_primary
case 2: // english
cell.skillInfo = skillList?[1];
cell.gameImage.tintColor = Utils.colorCode.language_primary
 
guard let gamesList = skillList?[CurrentIndexVal]["games_list"]
use like this.
 
i tried with my old code..bec i need time to understand and chnage the code..so only used my old code
@SyedQamarAbbas in my cellfor row or no of row method ?
 
7:58 AM
Your cellForRow is OK. There was just a little issue in your numberOfRows method.
 
agin crash
Thread 1: Fatal error: Index out of range
 
In your numberOfRow method just change the section to CurrentIndexVal
 
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
guard let gamesList = skillList?[CurrentIndexVal!]["games_list"] as? [[String: Any]] else {
return 0
}
return gamesList.count;
}
i changed
 
Thats because your numberOfRow method runs before setting array into `skillList`.
Have you set the tableView delegate/datesource from Storyboard or in the code?
 
yes
 
8:00 AM
```
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
guard let gamesList = FetchInfoUtil.sharedInstance.List[CurrentIndexVal!]["games_list"] as? [[String: Any]] else {
return 0
}
return gamesList.count;
}
```
 
both code and storyboard added
 
Remove from Storyboard and only use from code.
Now in your code first fetch the data and save it in your Array. And then set the delegate/dataSource to self.
Because when the datasource sets it starts calling the method numberOfRows. And in numberOfRow method you are accessing value from that array which has not yet been assigned any value so the crash is obvious.
 
Thread 1: Fatal error: Index out of range
in let gameInfo = gamesList[indexPath.item]
so confused, how to handle that
 
Have a break point on the line and detect why the crash occurred at first place.
 
initially its printing, when i scroll up and down getting crah
@objc func incomingNotification(_ notification: Notification) {

if let index = notification.userInfo?["indexValue"] as? Int {
print("view will appear with values")
CurrentIndexVal = index
}
self.chartsTableView.reloadData()
}
any issues with my reload data ?
CurrentIndexVal is my menuclick index value...not an list indexpath.row values
 
8:14 AM
Does scrolling up and down call this method? incomingNotification
 
no its an notification center method...only on click on my menu items it will call
currentIndexVal is my menuclick index value...not an list indexpath.row values ??
 
do not use skillList?[0] in your cellForRow try to use this..
 
Any issues bec of passing
 
cell.skillInfo = FetchInfoUtil.sharedInstance.List[0];
 
ok
let me try
 
8:17 AM
Got your point. You have Array of Dictionaries. And each dictionary contains another Array of gameList.

Outer Array manage the menu button click and inner array is the actual list displaying in your TableView right?
 
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
print("index values")
var indexv:Int?
switch CurrentIndexVal {
case 1: // focus
indexv = 0
case 2: // english
indexv = 1
case 3: // visual
indexv = 2
case 4: // problem solving
indexv = 3
case 5: // reasoning
indexv = 4
case 6: // memory
indexv = 5
default:
break;
}

guard let gamesList = KMFetchGamesInfoUtil.sharedInstance.skillsList?[indexv!]["games_list"] as? [[String: Any]] else {
return 0
}
return gamesList.count;
this is wokring fine
but is this an crt way ?
 
Yes it is a correct way but why you are using too much lines?
When you can write it in a single line.
instead of using it in switch statemant why don't you use like this?

KMFetchGamesInfoUtil.sharedInstance.skillsList?[(CurrentIndexVal - 1)]
 
what it does, actually i m not sure about this line
will it decrease the count ?. And if i reach measn my currentindex = 0 and -1 measn ?
 
Why don't you use 0 index for first menu and 1 for second instead of using 1 for first menu and 2 for second. this will be more simple.
Are you getting crash on your Last menu button?
 
i am using pagemenuViewcontroller...the default its comming from 0,1,2,3,4...but my actually menu starts from 1,2,3,4...and o is an default tuitorial page...not joined with an table view
its working fine..one more last question..hv u used PageMenuController?
 
8:25 AM
If you are assure that 0 will never be set in CurrentIndexVal then you can use (CurrentIndexVal - 1). But if you are not that much certain. Do not use this approach instead you previously used Switch case is better.
Yes i have used UIPageMenuController
 
how can i set the back ground color ? of that full view
in
method
full page menu option view...
 
Extreme background view's color?
 
in that image
top scroll view is there know
for menu names
that full scroll view i needs add background color
on func pageMenuController(_ pageMenuController: PageMenuController, didSelectMenuItem index: Int, direction: PageMenuNavigationDirection) {} this method
Any idea
 
You want to change background color of this entire Area?
Or the upper one? Or both Upper and this region?
 
not this one
in the link
menu option os coming right
mood,music, etc..
that scroll view
 
8:33 AM
OK. Can you share me which pod you are using for pageMenuController?
Here is your answer.
 
i done like this pageMenuController.tabMenuView.backgroundColor = UIColor.blue
its working finw
thanks a lot for ur time..to help me in this bug
 
9:11 AM
Can u help my fried too..stackoverflow.com/questions/54865142/… is having some issues..i too never handled firebase email auth passworless
0
Q: PassworLess email auth

kumark KI have done the passwordLess email authentication. And I got the link. Now when I redirect to my app. I needs to update the user to firebase authentication. And if its success allow them to go inside my app. Same time needs to get the current logged userid. Here is the code is used: logic is : ...

 

last day (15 days later) »