Skip to content

Instantly share code, notes, and snippets.

@DonMag
DonMag / sw1
Last active August 29, 2015 14:25
// Note: this will only rotate it 180 degrees, once
UIView.animateWithDuration(1.0,
animations: {self.arrowImageView.transform = CGAffineTransformMakeRotation(CGFloat(M_PI))}
)
// Note: this will rotate it 180 degrees, each time it's called
UIView.animateWithDuration(1.0,
animations: {self.arrowImageView.transform = CGAffineTransformRotate(self.arrowImageView.transform, CGFloat(M_PI))}
)
@DonMag
DonMag / inc1
Last active August 29, 2015 14:27
ProjRoot/
- folderA/sourceA.h
- folderA/sourceA.cpp
- folderB/sourceB.h
- folderB/sourceB.cpp
//in sourceB.h
//
// compare Time - Hour Minute Second - between two dates, ignoring the date part
- (BOOL)isTime:(NSDate *)d1 equalTo:(NSDate *)d2 {
unsigned int flags = NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond;
NSCalendar* calendar = [NSCalendar currentCalendar];
NSDateComponents* components1 = [calendar components:flags fromDate:d1];
NSDateComponents* components2 = [calendar components:flags fromDate:d2];
NSDate* timeOnly1 = [calendar dateFromComponents:components1];
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var myNavBar: UINavigationBar!
override func viewDidLoad() {
super.viewDidLoad()
///////
let time = "2015-10-29T05:22:15.000000Z"
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.SSS'Z'"
//dateFormatter.dateStyle = .ShortStyle
//dateFormatter.timeStyle = .ShortStyle
// if either Style line is uncommented,
// the next line shows an error
@DonMag
DonMag / define.m
Last active December 18, 2015 17:05
#define strA "Hello"
#define strB "World"
#define strC strA " " strB
// strC is now defined as "Hello World" (without the quotes)
// then, later in code...
NSLog(@"Value of strC = [%s]", strC);
@DonMag
DonMag / simctl list output.txt
Created January 5, 2016 20:04
simctl list output
== Device Types ==
iPhone 4s (com.apple.CoreSimulator.SimDeviceType.iPhone-4s)
iPhone 5 (com.apple.CoreSimulator.SimDeviceType.iPhone-5)
iPhone 5s (com.apple.CoreSimulator.SimDeviceType.iPhone-5s)
iPhone 6 (com.apple.CoreSimulator.SimDeviceType.iPhone-6)
iPhone 6 Plus (com.apple.CoreSimulator.SimDeviceType.iPhone-6-Plus)
iPhone 6s (com.apple.CoreSimulator.SimDeviceType.iPhone-6s)
iPhone 6s Plus (com.apple.CoreSimulator.SimDeviceType.iPhone-6s-Plus)
iPad 2 (com.apple.CoreSimulator.SimDeviceType.iPad-2)
iPad Retina (com.apple.CoreSimulator.SimDeviceType.iPad-Retina)
UIBezierPath *shadowPath = [UIBezierPath bezierPathWithRect:view.bounds];
view.layer.masksToBounds = NO;
view.layer.shadowColor = [UIColor blackColor].CGColor;
view.layer.shadowOffset = CGSizeMake(5.0f, 5.0f);
view.layer.shadowOpacity = 1.0f;
view.layer.shadowPath = shadowPath.CGPath;
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "HH:mm a"
let date = dateFormatter.dateFromString("11:42 am")
Interesting behavior (bug?) in Xcode / IB....
1) Create new Single View project...
2) Add a couple objects to the default ViewController in Main.storyboard...
3) Add a new Storyboard via File -> New -> File -> Storyboard...
4) Back in Main.storyboard, select either View Controller or View Controller Scene...
5) Select Edit -> Copy (or just cmd+C)
6) In the new Storyboard, try to Paste -- can't do it...
7) Drag a ViewController to the new Storyboard...
8) Now try to Paste -- it works!