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 Foundation | |
let date = NSDate() | |
var dateArrayCalendar = [String]() | |
let components = NSCalendar.currentCalendar().components([.Day , .Month , .Year], fromDate: date) | |
let year = components.year | |
let month = components.month | |
let dateFormatatter = NSDateFormatter() | |
let day = 1 // Output is [2,3,4] | |
// let day = 0 than o/p [1,2,3,4,5] |
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
// | |
// ViewController.swift | |
// carouselTest | |
// | |
// Created by Paul Wilkinson on 28/09/2016. | |
// Copyright © 2016 Paul Wilkinson. All rights reserved. | |
// | |
import UIKit | |
import iCarousel |
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
if let receiptURL = NSBundle.mainBundle().appStoreReceiptURL { | |
print("Fetching local receipt") | |
if let receipt = NSData(contentsOfURL: receiptURL) { | |
print("fetched") | |
let b64 = receipt.base64EncodedStringWithOptions([]).stringByReplacingOccurrencesOfString("+", withString: "%2B") | |
self.validateReceipt(b64) | |
} else { | |
print("Could not retrieve app store receipt") | |
} | |
} else { |
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 | |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view, typically from a nib. | |
if let url = URL(string: "http://seemeclothing.xyz/service.php") { | |
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
// | |
// BTConnectionHandler.swift | |
// AdTableTest | |
// | |
// Created by Paul Wilkinson on 24/06/2016. | |
// Copyright © 2016 Paul Wilkinson. All rights reserved. | |
// | |
import Foundation | |
import CoreBluetooth |
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
// | |
// AppDelegate.m | |
// DefaultsTest | |
// | |
// Created by Paul Wilkinson on 24/06/2016. | |
// Copyright © 2016 Paul Wilkinson. All rights reserved. | |
// | |
#import "AppDelegate.h" |
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
if ([self canFlash]) { | |
self.flashLabel.text = self.sentences[self.sentenceCounter][self.wordCounter]; | |
self.wordCounter++; | |
if (self.wordCounter == [self.sentences[self.sentenceCounter] count]) { | |
self.sentenceCounter++; | |
self.wordCounter = 0; | |
} | |
} |
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
// | |
// ViewController.swift | |
// AdTableTest | |
// | |
// Created by Paul Wilkinson on 15/06/2016. | |
// Copyright © 2016 Paul Wilkinson. All rights reserved. | |
// | |
import UIKit |
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 vowels=["a","e","i","o","u"] | |
let vowelSet = NSCharacterSet(charactersInString: "aeiou") | |
func findVowelAndReplace(start: NSString, end: NSString) -> [String] { | |
let vowelPosition = end.rangeOfCharacterFromSet(vowelSet) | |
var outputArray = [String]() | |
if vowelPosition.location != NSNotFound { | |
let newEnd = end.substringFromIndex(vowelPosition.location+1) | |
let newStart = end.substringToIndex(vowelPosition.location) | |
for vowel in vowels { |
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
NSString *url = @"https://www.google.com"; | |
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; | |
// [request setValue:@"api.example.com" forHTTPHeaderField:@"Host"]; | |
[request setValue:@"http://www.examplegood.com/" forHTTPHeaderField:@"Referer"]; | |
[request setURL:[NSURL URLWithString:url]]; | |
[request setHTTPMethod: @"GET"]; | |
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { | |
NSLog(@"%@",response); | |
NSLog(@"%@",error); | |
NSString* resultStr = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; |