2016-11-01 4 views
0
Iビュー・コントローラIこの

IOSのアプリケーションをクラッシュ通知オブジェクトから配列を渡す10

if let info = sender.userInfo as? Dictionary<String,[String]> { 
     // Check if value present before using it 
     if let s = info["sortoption"] { 

      if info["sortoption"]?.count > 0 
      { 
       JLToast.makeText("2", duration: 2).show() 

       let s :[String] = info["sortoption"]! 


       self.genreFilter.removeAll() 
       self.genreFilter = [] 
       self.genreFilter.appendContentsOf(s) 


      } 
     } 
    } 
としてデータを受け入れる午前の受信に別の

self.genreString.append("Comedy") 
self.sortByString.append("orderly") 
let myDict:Dictionary<String, [String]> = ["sortoption": self.genreString, "contenttype":self.sortByString] 

NSNotificationCenter.defaultCenter().postNotificationName("SecondViewControllerDismissed", object: nil, userInfo: myDict) 

にビューコントローラから以下のコードを投稿してい

しかし、配列は初期化されていません、その言っ!!!次のコード

答えて

0

はXCodeの遊び場

import Foundation 
import PlaygroundSupport 

PlaygroundPage.current.needsIndefiniteExecution = true 

let myDict:Dictionary<String, [String]> = ["sortoption": ["Comdedy"], "contenttype": ["orderly"]] 

NotificationCenter.default.addObserver(forName: NSNotification.Name(rawValue: "SecondViewControllerDismissed"), object: nil, queue: OperationQueue.main) { 
    notification in 
    if let info = notification.userInfo as? Dictionary<String,[String]> { 
     // Check if value present before using it 
     if let s = info["sortoption"] { 
      print(s) 
     } 
    } 
} 

NotificationCenter.default.post(name: NSNotification.Name(rawValue: "SecondViewControllerDismissed"), object: nil, userInfo: myDict) 
+0

こんにちはOstapで正常に動作これは、iOS 9.1でコンパイルしますか? – Saty

関連する問題