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
@interface UILabelStrikethrough : UILabel { | |
int xOffset; | |
int yOffset; | |
int widthOffset; | |
int stroke; | |
UIColor* strokeColor; | |
} | |
@property (nonatomic) int xOffset; | |
@property (nonatomic) int yOffset; | |
@property (nonatomic) int widthOffset; |
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
import Foundation | |
class Singleton { | |
class var sharedInstance: Singleton { | |
struct Static { | |
static var onceToken: dispatch_once_t = 0 | |
static var instance: Singleton? = nil | |
} | |
dispatch_once(&Static.onceToken) { | |
Static.instance = Singleton() |
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
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
_ = NSTimer.scheduledTimerWithTimeInterval(1.0/30.0, target: self, selector: #selector(ViewController.methodName), userInfo: nil, repeats: true) | |
} | |
func methodName(){ | |
print("Method Called") | |
} | |
} |
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
@interface compressBytes : NSObject { | |
z_stream zStream; | |
} | |
- (NSData *)compressBytes:(Bytef *)bytes length:(NSUInteger)length error:(NSError **)err shouldFinish:(BOOL)shouldFinish; |
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
class ViewController: UIViewController { | |
var label : UILabel! = nil | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
self.label = UILabel(frame: CGRect(x: 0, y: 0, width: 300, height: 21)) | |
self.label.font = UIFont.preferredFont(forTextStyle: .footnote) | |
self.label.textColor = .black | |
self.label.center = CGPoint(x: 200, y: 300) |
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
let alert = NSAlert() | |
alert.messageText = "Enter Message" | |
alert.informativeText = "Enter Informative Message" | |
alert.alertStyle = NSInformationalAlertStyle | |
alert.addButton(withTitle: "OK") | |
alert.addButton(withTitle: "Cancel") | |
alert.beginSheetModal(for: self.window, completionHandler: { (modalResponse) in | |
if(modalResponse == NSAlertFirstButtonReturn){ |
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
let alertController = UIAlertController(title: nil, message: alertMessageString, preferredStyle: .alert) | |
let cancelAction = UIAlertAction(title: alertLeftBtuTitle, style: .default, handler: nil) | |
alertController.addAction(cancelAction) | |
let okAction = UIAlertAction(title: alertRightBtnText , style: UIAlertActionStyle.default, handler: { | |
(action) -> Void in | |
print("ok tapped") | |
}) | |
okAction.isEnabled = false | |
alertController.addAction(okAction) |
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
func fetchCount(array: [Int], length: Int, symmetric: Bool) -> Int { | |
var count = 0 | |
for index in array.indices where index + length < array.count { | |
let subArray = array[index..<(index + length)] | |
print("Sub-array \"\(subArray)\" is \(subArray.allEqual() == true ? "Symmetrical" : "Asymmetrical")") | |
if symmetric == subArray.allEqual() { | |
count = count + 1 | |
} | |
} |
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
override func viewDidLoad() { | |
super.viewDidLoad() | |
let slider = UISlider(frame:CGRectMake(70, 550, 280, 20)) | |
slider.minimumValue = 0 | |
slider.maximumValue = 100 | |
slider.continuous = true | |
slider.tintColor = UIColor.redColor() | |
slider.value = 50 | |
slider.addTarget(self, action: #selector(ViewController.sliderValueDidChange(_:)), forControlEvents: .ValueChanged) | |
self.view.addSubview(slider) |
OlderNewer