[英]How to retrieve text from UITextView set in storyboard using auto generated key in Swift?
I have a directory structure something like this我有一个类似这样的目录结构
MyApp
|-ExternalFrameworks
|-MyApp
|-Storyboards
| |
| |-Dashboard.storyboard
| |-News.storyboard
| |-Social.storyboard
| | |
| | |-Social.strings(English)
| | |-Social.strings(French)
And suppose the autogenerated string is "hn8-xyz" sore some key in the.strings file.并假设自动生成的字符串是“hn8-xyz”,在.strings 文件中有一些键。 I need to extract the value string associated with the key.
我需要提取与键关联的值字符串。
I've found the the method to extract the string that is我找到了提取字符串的方法
NSLocalizedString(key: String, tableName: String?, bundle: Bundle, value: String, comment: String)
What I am not able to figure out is, how to assign the bundle property in this method based on my dir structure?我无法弄清楚的是,如何根据我的 dir 结构在此方法中分配 bundle 属性? I am primarily a java dev and not an iOS guy, but I've got this fix to do.
我主要是 java 开发人员,而不是 iOS 人,但我有这个修复要做。 Pardon my lack of framing the question as per Swift terminology.
请原谅我没有按照 Swift 术语提出问题。
Let me know if more information is needed to answer the question.让我知道是否需要更多信息来回答这个问题。
For most apps, you only have one bundle, the main bundle.对于大多数应用程序,您只有一个捆绑包,即主捆绑包。 If you look at the declaration of the function:
如果您查看 function 的声明:
func NSLocalizedString(_ key: String, tableName: String? = nil, bundle: Bundle = Bundle.main, value: String = "", comment: String) -> String
The bundle
parameter has a default value of Bundle.main
. bundle
参数的默认值为Bundle.main
。 You can probably just skip that parameter entirely.您可能可以完全跳过该参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.