Giter Club home page Giter Club logo

Comments (3)

phracek avatar phracek commented on July 22, 2024

My code in tableview is following:

    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        print(indexPath)
        print(indexPath.row)
        let action1 = PopMenuDefaultAction(title: "Add / Remove from favorites", didSelect: {action in
            let row_id = self.paragraphRowData[indexPath.row].id
            print(row_id)
            if self.get_favorites(id: row_id) == false {
                print("Add to favorites")
                self.paragraphRowData[indexPath.row].fav = true
                self.favorites.append(row_id)
            }
            else
            {
                print("remove")
                self.paragraphRowData[indexPath.row].fav = false
                if let index = self.favorites.firstIndex(of: row_id) {
                    self.favorites.remove(at: index)
                }
            }
            print(self.favorites)
            self.userDefaults.set(self.favorites, forKey: "Favorites")
            self.tableView.beginUpdates()
            self.tableView.reloadData()
            self.tableView.endUpdates()
        })
        let action2 = PopMenuDefaultAction(title: "Show references", didSelect: {action in
            print("Paragraphs")
        })
        let manager = PopMenuManager.default
        manager.addAction(action1)
        manager.addAction(action2)
        manager.present(on: self)
}

But for now I still getting the same row_id, when application is run.
My code is available on GitHub https://github.com/phracek/Katechismus_katolicke_cirkve_iOS/blob/master/KatechismusKatolickeCirkve/KatechismusKatolickeCirkve/Controllers/ParagraphTableViewController.swift#L134

from popmenu.

CaliCastle avatar CaliCastle commented on July 22, 2024

@phracek thanks for the details, I'll look into it

from popmenu.

ins0u avatar ins0u commented on July 22, 2024

Same problem :/

I still getting the same row_id in my app too..

Do you know why ?


Solution :

Store your value (row_id) in a class variable and use it everywhere..

it worked for me :)

from popmenu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.