Sto facendo un'applicazione di quiz di base. Le scelte sono sotto forma di una vista tabella. Se l'utente passa a una domanda precedente, voglio mostrargli la sua scelta precedentemente selezionata. Ho memorizzato la scelta in NSUserDefaults. Come posso convertire questo valore int in NSIndexpath e usarlo nella mia vista tabella?Come convertire int in nsindexpath?
16
A
risposta
50
Vedi l'NSINdexPath UIKit Additions
Nel tuo caso è possibile utilizzare (Swift):
let indexPath = NSIndexPath(forRow: 0, inSection: 0)
Swift 3.0:
let indexPath = IndexPath(row: 0, section: 0)
4
duplicato di This post
ho copiato la risposta ricevuto per qui
Per un indice int:
NSIndexPath *path = [NSIndexPath indexPathWithIndex:index];
Crea indice dell'elemento nel nodo 0 a scegliere come da riferimento.
Per utilizzare l'indexPath in un UITableView, il metodo più appropriato è
NSIndexPath *path = [NSIndexPath indexPathForRow:yourInt inSection:section];
0
È possibile ottenere indexpath usando sottostante Codice
NSIndexPath *index = [NSIndexPath indexPathForRow:YOURINTSTORED inSection:0];
+1
Questo è ObjectiveC, non Swift – zisoft
Problemi correlati
- 1. Come convertire NSIndexPath in Int in Swift?
- 2. Come convertire NSIndexPath in NSInteger?
- 3. Come convertire NSIndexpath in NSInteger o semplicemente int?
- 4. Come convertire int * in int
- 5. Come convertire l'array int in int?
- 6. Come convertire QString in int?
- 7. NSIndexPath in Swift
- 8. Come incrementare un NSIndexPath
- 9. Come convertire int [] a int [,] - C#
- 10. Come convertire "Index" in "Int" in Swift?
- 11. Come convertire Long in Int in Kotlin?
- 12. Come convertire int in bigint in golang?
- 13. Come convertire double in int in swift
- 14. Come aggiungere più NSIndexPath in NSMutableArray
- 15. Come convertire int [] a byte []
- 16. Come creare NSIndexPath per TableView
- 17. come convertire int a uint
- 18. Come convertire IntPtr a int
- 19. Java: charAt convertire in int?
- 20. OCaml - Come posso convertire int in stringa?
- 21. Come convertire int in string su Arduino?
- 22. Come convertire Nonetype in int o stringa?
- 23. Come convertire An NSInteger in un int?
- 24. come convertire ascii in unsigned int
- 25. Come posso convertire BitArray in single int?
- 26. Come convertire int in enum value?
- 27. Come convertire un int in una stringa?
- 28. Come convertire il valore enum in int?
- 29. Come convertire la colonna Nvarchar in INT
- 30. Problemi con NSIndexPath come chiave in NSMutableDictionary?
Questo è ObjectiveC, non Swift – zisoft
Va bene, ma funziona lo stesso. Puoi suggerire una modifica al mio post con la versione del codice swift. Scommetto che c'è un metodo identico;) –
Potrebbe anche pubblicare la sua risposta. – Josh