-
-
Save augusteo/c8fdc481c70504245bbb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Playground - noun: a place where people can play | |
import UIKit | |
import Foundation | |
var textArray:[String?] = ["first", nil, "third", nil] | |
var isBigThumb:[Bool] = [false, false, false, true] | |
class testClass: NSObject { | |
var text:String? | |
var isBigThumb:Bool | |
init(text:String?, isBigThumb:Bool) { | |
self.text = text | |
self.isBigThumb = isBigThumb | |
} | |
func displayProperty() { | |
println("\(self.text) + \(self.isBigThumb)") | |
} | |
} | |
var classArray:[testClass] = [] | |
for i in 0...3 { | |
let t = testClass(text: textArray[i], isBigThumb: isBigThumb[i]) | |
t.displayProperty() | |
classArray.append(t) | |
} | |
let firstPredicate = NSPredicate(format: "text = 'first'") | |
let bigPredicate = NSPredicate(format: "isBigThumb = FALSE") | |
let first = (classArray as NSArray).filteredArrayUsingPredicate(firstPredicate!) | |
let big = (classArray as NSArray).filteredArrayUsingPredicate(bigPredicate!) | |
let bigSwift = classArray.filter { (x) -> Bool in | |
x.isBigThumb == true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment