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 fmt = NSDateFormatter() | |
fmt.weekdaySymbols // -> ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] | |
fmt.shortWeekdaySymbols // -> ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] | |
fmt.veryShortWeekdaySymbols // -> ["S", "M", "T", "W", "T", "F", "S"] | |
fmt.standaloneWeekdaySymbols // -> ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] | |
fmt.shortStandaloneWeekdaySymbols // -> ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] | |
fmt.veryShortStandaloneWeekdaySymbols // -> ["S", "M", "T", "W", "T", "F", "S"] |
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 JSONStringify(value: [String: AnyHashable],prettyPrinted:Bool = false) -> String{ | |
let options = prettyPrinted ? JSONSerialization.WritingOptions.prettyPrinted : JSONSerialization.WritingOptions(rawValue: 0) | |
if JSONSerialization.isValidJSONObject(value) { | |
do { | |
let data = try JSONSerialization.data(withJSONObject: value, options: options) | |
if let string = NSString(data: data, encoding: String.Encoding.utf8.rawValue) { | |
return string as String | |
} | |
} catch { |
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
resultsSize contains the size of the data source array, self.results, before new data is added from the data at newImages. | |
[self.collectionView performBatchUpdates:^{ | |
int resultsSize = [self.results count]; | |
[self.results addObjectsFromArray:newImages]; | |
NSMutableArray *arrayWithIndexPaths = [NSMutableArray array]; | |
for (int i = resultsSize; i < resultsSize + newImages.count; i++) | |
[arrayWithIndexPaths addObject:[NSIndexPath indexPathForRow:i inSection:0]]; |
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
Date Formats a: AM/PM | |
A: 0~86399999 (Millisecond of Day) | |
c/cc: 1~7 (Day of Week) | |
ccc: Sun/Mon/Tue/Wed/Thu/Fri/Sat | |
cccc: Sunday/Monday/Tuesday/Wednesday/Thursday/Friday/Saturday | |
d: 1~31 (0 padded Day of Month) | |
D: 1~366 (0 padded Day of Year) |
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
extension UIColor { | |
convenience init(red: Int, green: Int, blue: Int) { | |
assert(red >= 0 && red <= 255, "Invalid red component") | |
assert(green >= 0 && green <= 255, "Invalid green component") | |
assert(blue >= 0 && blue <= 255, "Invalid blue component") | |
self.init(red: CGFloat(red) / 255.0, green: CGFloat(green) / 255.0, blue: CGFloat(blue) / 255.0, alpha: 1.0) | |
} | |
convenience init(netHex:Int) { |
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
From within KeyChain export the following both in p12 format, without giving password: | |
Apple Development Push Services certificate as cert.p12 | |
primary key under Apple Development Push Services as pkey.p12 | |
In terminal go to the directory where you have exported the certificates and convert the p12 files to pem format and concatenate them as follows: | |
$ openssl pkcs12 -in pkey.p12 -out pkey.pem -nodes -clcerts | |
$ openssl pkcs12 -in cert.p12 -out cert.pem -nodes -clcerts | |
$ cat cert.pem pkey.pem > iphone_ck.pem |
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 stringArray = modelsList[indexPath.row].description.componentsSeparatedByCharactersInSet( | |
NSCharacterSet.decimalDigitCharacterSet().invertedSet) | |
let newString = stringArray.joinWithSeparator("") |
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
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{ | |
/************* For bottom to top animation *****************/ | |
if ([animationType isEqualToString:@"BottomToTop"]) { | |
UIView *cellContentView = [cell contentView]; | |
CGFloat rotationAngleDegrees = -30; | |
CGFloat rotationAngleRadians = rotationAngleDegrees * (M_PI/180); | |
CGPoint offsetPositioning = CGPointMake(0, cell.contentView.frame.size.height*4); | |
CATransform3D transform = CATransform3DIdentity; | |
transform = CATransform3DRotate(transform, rotationAngleRadians, -50.0, 0.0, 1.0); |
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
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath | |
{ | |
UITabBarItem *item = self.items[indexPath.row]; | |
CGSize size = CGSizeMake(100, 30); | |
CGRect expectedLabelSize = [item.title boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:@{ NSFontAttributeName:[UIFont VWTextOfficeRegularWithSize:12] } context:nil]; | |
CGFloat height = CGRectGetHeight(collectionView.frame); | |
CGFloat width = ceilf(expectedLabelSize.size.width) + 40; | |
NewerOlder