This file contains hidden or 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
| let sourceImage = UIImage(named: "swift1.png") | |
| let maskImage = UIImage(named: "mask1.png") | |
| let maskImageRef = maskImage!.CGImage | |
| let sourceImageRef = sourceImage!.CGImage | |
| let mask = CGImageMaskCreate(CGImageGetWidth(maskImageRef), | |
| CGImageGetHeight(maskImageRef), | |
| CGImageGetBitsPerComponent(maskImageRef), |
This file contains hidden or 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
| struct SomeObject { | |
| var variable: String? | |
| init() { | |
| self.variable = "test" | |
| } | |
| } | |
| var j = 1 |
This file contains hidden or 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
| do { | |
| let jsonDict = try NSJSONSerialization.JSONObjectWithData(fileContents!, options: []) as! NSDictionary | |
| if let features = jsonDict["features"] as? [Dictionary<String, AnyObject>] { | |
| // try this | |
| var oneFeature = features[0]["geometry"]!["coordinates"]!![0][3] | |
This file contains hidden or 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
| import Cocoa | |
| @NSApplicationMain | |
| class AppDelegate: NSObject, NSApplicationDelegate { | |
| // local variable reference so we can call funcs in ViewController class | |
| var vc: ViewController? | |
| @IBAction func click(sender: NSMenuItem) { |
This file contains hidden or 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
| // | |
| #import <UIKit/UIKit.h> | |
| @interface ViewController : UIViewController | |
| @end |
This file contains hidden or 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
| var v1: UIView | |
| // this seems ok? | |
| guard let vvv = UINib(nibName: "SampleView", bundle: nil).instantiateWithOwner(nil, options: nil)[0] as? UIView else { return } | |
| v1 = vvv | |
| // but this won't compile? | |
| guard v1 = UINib(nibName: "SampleView", bundle: nil).instantiateWithOwner(nil, options: nil)[0] as? UIView else { return } |
This file contains hidden or 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
| //var myViews = self.view.subviews where ("some way to say subview-type is UIButton") | |
| var myViews = self.view.subviews.flatMap{ $0 as? UIButton } // thanks bhargavg !!! | |
| // next task: get a sub-array based on object properties? | |
| //var myViews = self.view.subviews.flatMap{ $0 as? UIButton "where $0.backgroundColor == UIColor.yellowColor()" } | |
| // this works - thanks DrYucatan |
This file contains hidden or 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
| I need a RegEx... | |
| All lines which: | |
| DO CONTAIN "Created by" | |
| but | |
| DO NOT CONTAIN "Don" or "Joe" or "Bob" | |
| So, for the following lines: |