2016-09-20 68 views
-1

如何將updateHeaderNotifications和DebugAlert分配給NSlocalizedString?我試圖添加updateHeaderNotifications = Nslocalized("text_text"),但它不起作用。求助switch語句分配給NSlocalizedString

private func initViewToCurrentState(pocketStatus: pocketStatus?) { 
    if let status = pocketStatus { 
     switch status { 
     case .Created: 
      **updateHeaderNotifications** ("text1") 
      initpocketBeforeTripView() 

     case .Paid: fallthrough 
     case .Undone: fallthrough 
     case .Aborted: fallthrough 
     default: 
      PocketRideService.sharedInstance.removeCachedRide() 
      dismissViewControllerAnimated(false, completion: { 
       DebugAlert.show("text") 

      }) 
     } 
    } 
} 
+1

如何updateHeaderNotifications定義? – matsoftware

回答

0

感謝根據您的方法定義,你可以使用如下:

private func updateHeaderNotifications(bigNotify: String, smallNotify: String) { 
    bigNotification.text = NSLocalizedString(bigNotify, comment: "bigNotify")//you can set any text for comment parameter 
    smallNotification.text = NSLocalizedString(smallNotify, comment: "smallNotify") 
} 

,並在您switch聲明:

 case .Created: 
     updateHeaderNotifications("text1", smallNotify: "text2") 
+0

我可以這樣嗎? –

+0

case .Created: updateHeaderNotifications(NSLocalizedString(「AA_AA」),NSLocalizedString(「AA_AA2」)) initRouteBeforeTripView()) –

+0

'NSLocalizedString',需要兩個參數。是的,您可以嘗試在開關中設置文字。 – Santosh