有谁可以帮助我吗
我正在尝试使用Swift语言创建一个IOS应用程序,我需要使用Hijri(伊斯兰)日历
我尝试了很多次但是我失败了:(
这是我的尝试
let datenow = NSDate()
let calendar = NSCalendar.currentCalendar()
let components = calendar.components(NSCalendarUnit(UInt.max), fromDate: datenow)
var gregorian = NSCalendar(identifier:NSIslamicCivilCalendar)
var date = gregorian.dateFromComponents(components)
println(date)
Run Code Online (Sandbox Code Playgroud)
并且输出错误
2576-04-25 09:05:08 +0000
Run Code Online (Sandbox Code Playgroud)
我们在1434年在hijri而不是2576年!
我想在swift中搜索对象数组但我不知道如何:(
我试过了
filteredArrayUsingPredicate
Run Code Online (Sandbox Code Playgroud)
但仍然无法正常工作,它给了我一个错误信息
- 更新 -
错误信息是
swift:42:9: 'Array<search_options>' does not have a member named 'filteredArrayUsingPredicate'
Run Code Online (Sandbox Code Playgroud)
- 更新 -
class search_options {
let id:String
let option:String
init(){}
init(id:String ,option:String){
self.id = id
self.option = option
}
}
Run Code Online (Sandbox Code Playgroud)
我只想搜索选项变量
当我试图使用时
func searchBarSearchButtonClicked( searchBar: UISearchBar!)
{
let filteredArray = filter(search_options_array) { $0 == "test" }
println(searchBar.text)
}
Run Code Online (Sandbox Code Playgroud)
我收到了这条消息
swift:40:58: 'search_options' is not a subtype of 'String'
Run Code Online (Sandbox Code Playgroud)