보기 컨트롤러간에 전체 배열을 전달하려고하지만 누락 된 부분을 알아낼 수 없습니다. 뷰 컨트롤러 하나에빠른보기 컨트롤러간에 전체 배열 전달
나는이 :보기 컨트롤러 두에서
protocol ExclusionsViewViewControllerDelegate{
func ExcUpperDidFinish(controller:ExclusionsView)
func ExcLowerDidFinish(controller:ExclusionsView)
}
class ExclusionsView: UIViewController, UITableViewDataSource, UITableViewDelegate {
var delegate:ExclusionsViewViewControllerDelegate? = nil
var ExcLowerArray:[Int]=[]
var ExcUpperArray:[Int]=[]
@IBOutlet var ExcLowerText: UITextField!
@IBOutlet var ExcUpperText: UITextField!
@IBOutlet var ExcFreqTable: UITableView!
@IBAction func BackButton(sender: AnyObject) {
if (delegate != nil){
delegate!.ExcUpperDidFinish(self, Array: ExcUpperArray)
delegate!.ExcLowerDidFinish(self, Array: ExcLowerArray)
}
dismissViewControllerAnimated(true,completion:nil)
}
나는이 :
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, PreferencesViewControllerDelegate, ExclusionsViewViewControllerDelegate {
var ExcUpperFreqArray:[Int]=[]
var ExcLowerFreqArray:[Int]=[]
override func viewDidLoad() {
super.viewDidLoad()
}
func ExcLowerDidFinish(controller: ExclusionsView, Array:[Int]) {
ExcLowerFreqArray = Array
controller.navigationController?.popViewControllerAnimated(true)
}
func ExcUpperDidFinish(controller: ExclusionsView, Array:[Int]) {
ExcUpperFreqArray = Array
controller.navigationController?.popViewControllerAnimated(true)
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
if segue.identifier == "pushExclusions"{
let zc = segue.destinationViewController as ExclusionsView
zc.ExcLowerArray = ExcLowerFreqArray
zc.ExcUpperArray = ExcUpperFreqArray
}
}
내가 제대로 배열을 참조하는 방법을 알아낼 수 없습니다. 보기 컨트롤러 1에서 배열 ExcLowerArray를 만들려고합니다.보기를 변경하면 두 번째보기 컨트롤러에서 모든 데이터를 ExcLowerFreqArray에 복사하므로 해당보기 컨트롤러에서 참조 할 수 있습니다. 순간 나는이 두 줄에 오류가 얻을하지만! 대리자를 .ExcLowerDidFinish (자기, 배열 : ExcLowerArray) FUNC의 ExcLowerDidFinish을 (컨트롤러 : ExclusionsView, 배열 : [지능]) {
문제에 대해 조금 더 자세히 설명해 주시겠습니까? 배열 참조가 전달되기를 원하지만 복사본이 대신 생성됩니까? – Antonio