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
// created Michael Katz November 2019 | |
// MIT licensed | |
import SwiftUI | |
struct ContentView: View { | |
@State var start: Bool = false | |
var animationToExplore: Animation { | |
// replace this animation with the animation you want to graph |
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
//the log manager's log method. Each log channel formats its message and then sends the whole string to this method | |
- (void) log:(NSString*)message | |
{ | |
if (self.logSink == nil) { | |
NSLog(@"%@", message); | |
} else { | |
[self.logSink log:message]; | |
} | |
} |
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 DEBUG | |
#define AssertLog(condition, desc, args...) NSAssert(condition, desc, ## args) | |
#define DBLog(format, args...) TFLog(@"%s, line %d: " format "\n", __func__, __LINE__, ## args); | |
#else | |
#define AssertLog(c, desc, args...) if (!(c)) TFLog(@"%s, line %d: " desc "\n", __func__, __LINE__, ## args); | |
#define DBLog(format, args...) do {} while(0) | |
#endif |
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
for (NSString* familyName in [UIFont familyNames]) { | |
NSLog(@"%@",[UIFont fontNamesForFamilyName:familyName]); | |
} |
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
+ (UIImage*) imageWithColor:(UIColor*)color size:(CGSize)size | |
{ | |
UIGraphicsBeginImageContext(size); | |
UIBezierPath* rPath = [UIBezierPath bezierPathWithRect:CGRectMake(0., 0., size.width, size.height)]; | |
[color setFill]; | |
[rPath fill]; | |
UIImage* image = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
return image; | |
} |
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
#define POLL_INTERVAL 0.05 //50ms | |
#define N_SEC_TO_POLL 1.0 //poll for 1s | |
#define MAX_POLL_COUNT N_SEC_TO_POLL / POLL_INTERVAL | |
#define CAT(x, y) x ## y | |
#define TOKCAT(x, y) CAT(x, y) | |
#define __pollCountVar TOKCAT(__pollCount,__LINE__) | |
#define POLL(__done) \ | |
NSUInteger __pollCountVar = 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
#define POLL_INTERVAL 0.05 //50ms | |
#define N_SEC_TO_POLL 1.0 //poll for 1s | |
#define MAX_POLL_COUNT N_SEC_TO_POLL / POLL_INTERVAL | |
- (void) testAnAsynchronousFunction | |
{ | |
__block BOOL done = NO; | |
//do async on a delay | |
float delayInSeconds = 0.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
KCSCollection* books = [KCSCollection collectionFromString:@"books" ofClass:[Book class]]; | |
KCSLinkedAppdataStore* store = [KCSLinkedAppdataStore storeWithCollection:books options:nil]; | |
[store loadObjectWithId:@"HPBook6" withCompletionBlock:^(NSArray *objectsOrNil, NSError *errorOrNil) { | |
Book* harryPotter = [objectsOrNil objectAtIndex:0]; | |
Author* jRowling = harryPotter.author; | |
} withProgressBlock:^(NSArray *objects, double percentComplete) { | |
//show progress | |
}]; |
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
//books.h | |
@interface Book : NSObject <KCSPersistable> | |
@property (nonatomic) Author* author; | |
@property (nonatomic) NSString* title; | |
@end | |
//books.m | |
@implementation Book | |
+(NSDictionary *)kinveyPropertyToCollectionMapping { | |
return @{@"author" : @"authors"}; |
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
- (id) init | |
{ | |
if (self = [super init]) { | |
self.tableValues = [NSArray array]; | |
} | |
return self; | |
} | |
- (void) viewWillAppear:(BOOL)animated | |
{ |
NewerOlder