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 urlString: String = "http://example.com" | |
var url: NSURL = NSURL(string: urlString)! | |
var data = NSData() | |
var request = NSMutableURLRequest(URL: url, cachePolicy: .UseProtocolCachePolicy, timeoutInterval: 60) | |
request.HTTPMethod = "GET" | |
var response: AutoreleasingUnsafeMutablePointer<NSURLResponse?> = nil | |
var error: NSErrorPointer = nil | |
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 date = NSDate() // Today's date. | |
let dateFormatter = NSDateFormatter() // Creating a dateFormatter object for making readable date | |
var array = [String]() // Store the today's date and last 7 date. | |
let secondInADay: NSTimeInterval = 24 * 60 * 60 // A day NSTimeInterval | |
let timeInterval = date.timeIntervalSince1970 // Today's NSTimeInteval | |
dateFormatter.dateFormat = "EE-yyyyMMdd" // Making a dateFormat | |
dateFormatter.locale = NSLocale(localeIdentifier:"us") // | |
array.append(dateFormatter.stringFromDate(date)) // Adding today's date in to the array |
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
if(MessageBox.Show("Are you sure?", "Yes", MessageBoxButtons.YesNo) == DialogResult.Yes) | |
{ | |
//code here... | |
} | |
else | |
{ | |
//code here... | |
} |
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
private void textBoxKeyPressLetter(object sender, KeyPressEventArgs e) | |
{ | |
if (!char.IsControl(e.KeyChar) && !char.IsLetter(e.KeyChar) && | |
(e.KeyChar != '.')) | |
{ | |
e.Handled = true; | |
} | |
// only allow one decimal point | |
if ((e.KeyChar == '.') && ((sender as TextBox).Text.IndexOf('.') > -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
private void textBoxKeyPressNumber(object sender, KeyPressEventArgs e) | |
{ | |
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && | |
(e.KeyChar != '.')) | |
{ | |
e.Handled = true; | |
} | |
// only allow one decimal point | |
if ((e.KeyChar == '.') && ((sender as TextBox).Text.IndexOf('.') > -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
let decimalInteger = 17 | |
let binaryInteger = 0b10001 // 17 in binary notation | |
let octalInteger = 0o21 // 17 in octal notation | |
let hexadecimalInteger = 0x11 // 17 in hexadecimal notation | |
let decimalNumber = 1.25e2 // 125.0 e2 means 10^2 | |
let decimalNumber2 = 1.25e-2 // 0.0125 e-2 means 10^-2 | |
let hexadecimalExponent = 0xFp2 // 60.0 means 15x2^2 | |
let hexadecimalExponent2 = 0xFp-2 // 3.75 means 15x2^-2 |
NewerOlder