Ios 将每个新Swift区块链SmartContract发送者的按钮操作输入TableView列
简单地说,我正在开发一个具有教育意义的区块链应用程序,其中SmartContract使用简单的信息创建,如“提供者”、“目的地者”和“金额”,需要在后端以完全透明的方式发送,我可以在一个小窗口中插入这些信息。我希望每个事务详细信息都显示在新的TableView ViewController中的一个新列中,每个事务都具有提供者Destinator和Amount,并通过单击每个列中的事务来描述事务代码 我能够创建一个onTapButton,创建一个新事务并在SHA256中对其进行哈希,然后将其输出为JSON。现在我要做的就是在每一列中发送交易信息,我还在为如何做到这一点而挠头。以下是一些源代码,不涉及太多细节: 交易(App.swift) JSON编码器(App.swift) onTapButton(ViewController.swift) 打印功能(ViewController.swift) 以下是我希望它在TableView的第二个ViewController中的外观: 下面是我们正在查看的应用程序计划: 我希望代码和照片之间有足够的描述性Ios 将每个新Swift区块链SmartContract发送者的按钮操作输入TableView列,ios,swift,iphone,xcode,blockchain,Ios,Swift,Iphone,Xcode,Blockchain,简单地说,我正在开发一个具有教育意义的区块链应用程序,其中SmartContract使用简单的信息创建,如“提供者”、“目的地者”和“金额”,需要在后端以完全透明的方式发送,我可以在一个小窗口中插入这些信息。我希望每个事务详细信息都显示在新的TableView ViewController中的一个新列中,每个事务都具有提供者Destinator和Amount,并通过单击每个列中的事务来描述事务代码 我能够创建一个onTapButton,创建一个新事务并在SHA256中对其进行哈希,然后将其输出为
class Transaction : Codable {
var from :String
var to :String
var amount :Double
}
var key : String {
get {
let transactionsData = try! JSONEncoder().encode(self.transactions)
let transactionsJSONString = String(data: transactionsData, encoding: .utf8)
return String(self.index) + self.previousHash + String(self.nonce) + transactionsJSONString!
}
}
@IBAction func onTapSendButton(_ sender: UIButton) {
self.generateDummyTransactions()
let str:String = "Mary"
self.providerForm.text = str
let str2:String = "Bob"
self.destinatorForm.text = str2
//let int:Double = 20.0
//self.amountSum. = int
}
func generateDummyTransactions() {
_ = self.providerForm
_ = self.destinatorForm
_ = self.amountSum
let transaction = Transaction(from: "Mary", to: "Bob", amount: 20, transactionType: TransactionType.domestic)
let block1 = Block()
block1.addTransaction(transaction: transaction)
let transaction2 = Transaction(from: "Phil", to: "Gab", amount: 10.0, transactionType: .domestic)
block1.addTransaction(transaction: transaction2)
print("------------------------------------------------------")
let block = blockchain.getNextBlock(transactions: [transaction])
blockchain.addBlock(block)
// print(blockchain.blocks.count)
let data = try! JSONEncoder().encode(blockchain)
let blockchainJSON = String(data : data, encoding: .utf8)
print(blockchainJSON!)
realTimeTextOutput.text = blockchainJSON
}