Skip to content

Instantly share code, notes, and snippets.

View liu044100's full-sized avatar
🌴
On vacation

Rain liu044100

🌴
On vacation
View GitHub Profile
@liu044100
liu044100 / BinaryGap
Created November 14, 2016 02:42
BinaryGap_Objective_C
-(int)binaryGap:(int)N {
NSString *string = @"";
NSUInteger x = N;
while (x>0) {
string = [[NSString stringWithFormat: @"%lu", x&1] stringByAppendingString:string];
x = x >> 1;
}
int longestBinaryGap = 0;
int binaryGapLength = 0;
```swift
protocol OutsideTileContainerDelegate {
func outsideTileContainer(container: TileContainer)
}
class TileContainer: UIView {
//MARK: OutsideTileContainerDelegate
var delegate: OutsideTileContainerDelegate?
@liu044100
liu044100 / swift
Last active January 28, 2016 07:51
class func createCustomItemView() -> CustomItemView? {
let bundle = NSBundle(forClass: CustomItemView.self)
let nib = UINib(nibName: "CustomItemView", bundle: bundle)
if let view = nib.instantiateWithOwner(self, options: nil).first as? CustomItemView {
return view
}
return nil
}
private class func addEqualConstraintsFromSubView(subView: UIView, toSuperView superView: UIView) {