Skip to content

Instantly share code, notes, and snippets.

View Morse-Code's full-sized avatar

Christopher Morse Morse-Code

View GitHub Profile
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *const cellContactIdentifier = @"ContactInfoCell";
static NSString *const cellCompanyIdentifier = @"CompanyCell";
static NSString *const cellDeleteIdentifier = @"DeleteCell";
static NSString *const cellDatePickerIdentifier = @"DatePicker";
static NSString *const cellAddPhoneIdentifier = @"AddPhoneCell";
static NSString *const cellAddressIdentifier = @"AddressCell";
static NSString *const cellCommentIdentifier = @"CommentCell";
static NSString *const cellMobilePhoneIdentifier = @"MobilePhoneCell";
import Foundation
class Box<T> {
let unbox: T
init(_ value: T) { self.unbox = value }
}
struct Notification<A> {
let name: String
}
dispatch_group_t group = dispatch_group_create();
dispatch_semaphore_t semaphore = dispatch_semaphore_create(10);
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
for (int i = 0; i < 100; i++)
{
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
dispatch_group_async(group, queue, ^{
NSLog(@"%i",i);
sleep(2);
dispatch_semaphore_signal(semaphore);
@Morse-Code
Morse-Code / RoundFloat.m
Last active August 29, 2015 13:59
Use NSDecimalNumberHandler with NSDecimalNumber to round floating point value to closest value of specified precision (scale).
float toRound = 0.999322;
short precision = 3;
NSDecimalNumberHandler *handler = [NSDecimalNumberHandler decimalNumberHandlerWithRoundingMode:NSRoundPlain
scale:precision
raiseOnExactness:YES
raiseOnOverflow:YES
raiseOnUnderflow:YES
raiseOnDivideByZero:YES];
float rounded = [[[NSDecimalNumber decimalNumberWithString:[[NSNumber numberWithFloat:toRound] stringValue]] decimalNumberByRoundingAccordingToBehavior:handler] floatValue];
NSLog(@"%f", rounded);
@Morse-Code
Morse-Code / Asset.m
Created May 24, 2013 16:26
Check for Existence Substring in String
NSString *str = @"product.orderEntryListItem.orderItem.caseDiscount";
BOOL found = [str rangeOfString:@"Discount"].location != NSNotFound;
NSLog(@"%d", found);
$ sudo apachectl stop
$ sudo launchctl unload /System/Library/LaunchDaemons/org.apache.httpd.plist
@Morse-Code
Morse-Code / PinForColor.m
Created April 29, 2013 03:09
Get reusable map pin; specify color of pin.
+ (NSString *)reusableIdentifierForPinColor :(MKPinAnnotationColor)paramColor
{
NSString *result = nil;
switch (paramColor) {
case MKPinAnnotationColorRed:
{
result = REUSABLE_PIN_RED;
break;
}
@Morse-Code
Morse-Code / ZoomToCurrentLocation.m
Created April 29, 2013 03:04
Zoom map region to current location.
- (IBAction)zoomToCurrentLocation:(id)sender
{
NSLog(@"zoomToCurrentLocation");
//Start updating location because we want it...
[_myLocationManager startUpdatingLocation];
NSLog(@"lat: %f", _myLocationManager.location.coordinate.latitude);
NSLog(@"long: %f", _myLocationManager.location.coordinate.longitude);
@Morse-Code
Morse-Code / ToggleMapType.m
Created April 29, 2013 03:03
MapKit map type three way toggle.
- (IBAction)toggleMapType:(id)sender
{
NSLog(@"toggleMapType");
mapType = (mapType + 1) % 3;
if (mapType == 0) {
self.dangerMap.mapType = MKMapTypeStandard;
}
else if (mapType == 1) {

Generate the list yourself:

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/
  Developer/SDKs/iPhoneOS*.sdk/System/Library/Frameworks/UIKit.framework/Headers
$ grep -H UI_APPEARANCE_SELECTOR ./* | sed 's/ __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_5_0) UI_APPEARANCE_SELECTOR;//'

UIActivityIndicatorView