« first day (2120 days earlier)      last day (1863 days later) » 

03:40
this is my json response
this is what i have done so far
how to get the data key values with id and state
 
3 hours later…
06:40
morning
07:26
Morning \m/
 
3 hours later…
10:30
@Shubhank: koi idea hain bhai
FAILURE: responseSerializationFailed(reason: Alamofire.AFError.ResponseSerializationFailureReason.jsonSerializationFailed(err‌​or: Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 0." UserInfo={NSDebugDescription=Invalid value around character 0.}))
esi error aa rahi hain
try increasing timeoutInterval of api
inside code @VikramThakor
10:56
there is already manager.session.configuration.timeoutIntervalForRequest = 120
11:29
@VikramThakor response is not json
 
2 hours later…
Wez
Wez
13:45
Afternoon
evening :D
Wez
Wez
Working late?
@Shubhank hii
nope, gonna leave
yes @dilip ?
i have a label inside cell
which displays "2000.00" values
how can i add each label and show on a label outside tableview
i tried map and reduce method but i could not get
13:55
?
what does it mean
Wez
Wez
Whats your datasource look like @DilipTiwari?
wait bro i will share screenshot
@Wez bro this is my json
which i displayed on label inside cell
struct SelectedSpecialization {

var id:String?
var price:String?
var special:String?

init(id:String,price:String,special:String) {
self.id = id
self.price = price
self.special = special
}
}
this is my model
Wez
Wez
so its one specialisation per cell?
yes bro
Wez
Wez
sounds simple enough
so whats not working?
13:59
how can i show total prices on a label outside tableview
Wez
Wez
Are you using a storyboard?
yes bro
            let prices = selectedSpeciality.map{($0.price)}.reduce(0.0, +)
this i tried
Wez
Wez
ah! ok
hmm
but i m getting error bro
Wez
Wez
whats the error?
bro
14:02
Cannot invoke 'reduce' with an argument list of type '(Double, _)'
Wez
Wez
;)
have you tried .reduce(0, +)
yes bro
then it gives Cannot invoke 'reduce' with an argument list of type '(Int, _)'
Wez
Wez
the ios docs show this
let numbers = [1, 2, 3, 4]
let numberSum = numbers.reduce(0, { x, y in
    x + y
})
hmm
ok let me try this
now
14:07
bro i m using xcode 9.4
do i need to import anything
Wez
Wez
don't think so
still issue bro
Anyone have experience with UITableView?
@PeterRuppert hiii
struct SelectedSpecialization {

var id:String?
var price:String?
var special:String?

init(id:String,price:String,special:String) {
self.id = id
self.price = price
self.special = special
}
}
@Wez this is my model
Wez
Wez
14:09
i just tested this
which one
Wez
Wez
i wrote an example
one second ill send it
Wez
Wez
14:11
try this
let prices = selectedSpeciality.reduce(0, { x, y in
    x + y.price
})
Wez
Wez
assuming your selectedSpeciality is an array of selected SelectedSpecialization's
OH
i just noticed
your price is a string
change your model so your price is an Int
or a Double
ok bro
1 min
Wez
Wez
although your JSON has price as a string too.
you might need to change that first, or if you can't then just convert it in the model.
yes bro
@Wez what i will convert in model
Wez
Wez
14:14
you'd need to do something like this

struct SelectedSpecialization {

var id:String?
var price:Int?
var special:String?

init(id:String,price:String,special:String) {
self.id = id
if let p = Int(price) {
self.price = p
}
self.special = special
}
ok bro
then bro
Wez
Wez
then?
is it working? do you have a total?
let me run now bro
@Wez it crashes
Wez
Wez
error?
Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value
Wez
Wez
14:22
please check my example
if let p = Int(price) {
self.price = p
}
Wez
Wez
assuming thats where it's crashing?
ok let me check
Wez
Wez
actually
you may have this issue elsewhere
ook bro i m checking again
Wez
Wez
14:29
you may also need to do this
let numberSum = array.reduce(0, { x, y in
x + (y.price ?? 0)
})
incase the price is nil
ook bro i m checking again
ok bro
ok bro
Wez
Wez
hi
yes bro
@Wez
Wez
Wez
14:43
Yes?
checking again
Wez
Wez
no problem
14:55
@Wez bro ur code is working fine
Wez
Wez
Ok, cool!
hmm
bro i more thing i want to ask
@MichaelDautermann hii bro how r u ?
Wez
Wez
whats that then? :)
bro i have a tableview
Wez
Wez
Nice
14:59
now what i m facing issue is
when i click on cell i have to check the button image and when i click on same cell i have to deselect cell with uncheck image of button
Wez
Wez
yep
and that same tableview have a multiple selection of tableview
Wez
Wez
is it working?
no bro
it is not working
when i select that cell i have to pass data of that cell to tableview in same view controller
and when i deselect i have to remove that data from other tableview
Wez
Wez
How are you doing this at the moment?
15:05
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let cell = tableView.cellForRow(at: indexPath) as? SpecialityCell
if cell?.isSelected == false{
print("cell not selected")
cell?.cellBtn.setBackgroundImage(UIImage(named: "checkBox"), for: .normal)
}
}

func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {

let cell = tableView.cellForRow(at: indexPath) as? SpecialityCell

if cell?.isSelected == false{
print("cell not selected")
cell?.cellBtn.setBackgroundImage(UIImage(named: "uncheckBox"), for: .normal)
Wez
Wez
Why don't you use your selectedSpeciality array to handle this?
Then in your cellForItemAt indexPath method change how cells look based on if they are in the selectedSpeciality array or not.
bro i have created two model for each tableview
Wez
Wez
`didSelectRow` should then just be responsible for adding and removing objects from the selected array.
and reloading the tableview
Wez
Wez
you've already written most of the code!
15:10
that also i m stuck bro
Wez
Wez
Whats your main array called? the one that is holding all the objects?
for which table
top or bottom table
Wez
Wez
lets start with the top one? then you can take the logic to the second
ok
specialityList
this is top tabel model array variable
Wez
Wez
ok
15:15
"specialityList"
hmm
Wez
Wez
?
can i show cell for row?
Wez
Wez
yeh?
let cell = tableView.dequeueReusableCell(withIdentifier: cellSpecialization) as? SpecialityCell
cell?.lblSpecialization.text = specialityList[indexPath.row].speciality
cell?.cellBtn.isEnabled = true
cell?.cellBtn.isUserInteractionEnabled = false
return cell!
Wez
Wez
ok
15:18
cellforrow
Wez
Wez
yh
then bro
???
Wez
Wez
just working on an example
Wez
Wez
this is un-tested .. but something like this - gist.github.com/lukewakeford/bc9bdc231beab39b09315c5dff747e29
15:26
ok bro
Wez
Wez
give it a go
and have a look at what it's doing
ok bro let me do now
@Wez bro one question
Wez
Wez
Hit me
Hi @MichaelDautermann :wave:
15:35
hey bro^2
Wez
Wez
bro
in cell for row
if selectedSpeciality.contains(where: { item -> Bool in
return item.id == object.id
}) {
cell.cellBtn.setBackgroundImage(UIImage(named: "checkBox"), for: .normal)
} else {
cell.cellBtn.setBackgroundImage(UIImage(named: "uncheckBox"), for: .normal)
}
Wez
Wez
yeh?
selected or unselected image would be for top
selectedSpeciality this is for bottom
Wez
Wez
okay, do you think you can handle it?
can you see what the code is doing?
do a little switcheroo
15:37
may be
Wez
Wez
give it a go
We can't write it all for you.
:D
i m confused
@Wez yes correct
some issue in above code which i posted recently
@Wez
Wez
Wez
whats the issue?
its gives error
Wez
Wez
whats the error?
15:44
one sec
@Wez here is error
Wez
Wez
8-)
check this erorr
Wez
Wez
16:00
i am looking
Wez
Wez
try making your model equatable
struct SelectedSpecialization:Equatable {
Wez
Wez
^
done
still error
Wez
Wez
16:05
same error? or new?
oh also
same error
Wez
Wez
you need to swap the array to the selectedSpeciality
// remove if already in the selected array
if let index = selectedSpeciality.index(of:object) {
selectedSpeciality.remove(at: index)
} else {
// append if not in the selected array
selectedSpeciality.append(object)
}
same errors
now in both
of:object

and

object
Wez
Wez
you may have to look in to these on stack, i've suggested a solution, I am not able to test.
not atm anyway
ok
thanks for support
bro
Wez
Wez
16:10
no prob, keep up the fight bro

« first day (2120 days earlier)      last day (1863 days later) »