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
// I take a string from a text field (which includes emoji) and apply this to it so that my JSON parser doesn't freak out when it comes back to me. | |
NSData *stringData = [message dataUsingEncoding:NSNonLossyASCIIStringEncoding]; | |
NSString *safeString = [[NSString alloc] initWithData:stringData encoding:NSUTF8StringEncoding]; | |
// I try to draw the string I get back from the server (I sent it safeString from above). | |
// When I draw it I end up getting text like this drawn: | |
// Test emoji \ud83d\ude03 |
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
- (void)animatePhotosIn | |
{ | |
CAKeyframeAnimation *userPhotoAnim = [CAKeyframeAnimation animationWithKeyPath:@"transform"]; | |
userPhotoAnim.values = [self photoTransformValuesWithMultiplier:1.0]; | |
CAKeyframeAnimation *matchPhotoAnim = [CAKeyframeAnimation animationWithKeyPath:@"transform"]; | |
matchPhotoAnim.values = [self photoTransformValuesWithMultiplier:-1.0]; | |
NSArray *photoAnims = [NSArray arrayWithObjects:userPhotoAnim, matchPhotoAnim, nil]; | |
for (CAKeyframeAnimation *photoAnim in photoAnims) { | |
photoAnim.calculationMode = kCAAnimationCubic; |
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
@interface CFYActivity : NSManagedObject | |
@property (nonatomic, strong) NSNumber * activityID; | |
@property (nonatomic, strong) NSNumber * type; | |
@property (nonatomic, strong) NSDate * date; | |
@property (nonatomic, strong) NSNumber * amount; | |
@property (nonatomic, strong) NSString * activityDescription; | |
@property (nonatomic, strong) NSNumber * rewardID; | |
@property (nonatomic, strong) CFYChain *chain; |
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
- (void)scrollViewDidScroll:(UIScrollView *)scrollView | |
{ | |
CGPoint contentOffset = scrollView.contentOffset; | |
UIView *header = self.tableView.tableHeaderView; | |
if (contentOffset.y <= 0.0f) { | |
header.frame = CGRectMake(CGRectGetMinX(header.frame), contentOffset.y, CGRectGetWidth(header.frame), CFY_DISCOVER_TABLE_HEADER_MIN_HEIGHT - contentOffset.y); | |
[self.mapView setCenterCoordinate:self.mapView.userLocation.coordinate animated:NO]; | |
} else { | |
header.frame = CGRectMake(CGRectGetMinX(header.frame), 0.0f, CGRectGetWidth(header.frame), CFY_DISCOVER_TABLE_HEADER_MIN_HEIGHT); | |
} |
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
#0 0x32a10960 in objc_exception_throw () | |
#1 0x3604bb3c in _PFFaultHandlerLookupRow () | |
#2 0x3604d0fe in _PF_FulfillDeferredFault () | |
#3 0x36054c10 in _PF_ManagedObject_WillChangeValueForKeyIndex () | |
#4 0x3605f332 in _sharedIMPL_setvfk_core () | |
#5 0x0009c4f2 in __block_global_0 at /Users/Jonathan/Projects/matchbox_ios/matchbox/matchbox/MBUser.m:60 | |
#6 0x36068bc0 in developerSubmittedBlockToNSManagedObjectContextPerform () | |
#7 0x333f04b6 in _dispatch_client_callout () | |
#8 0x333f51bc in _dispatch_main_queue_callback_4CF$VARIANT$mp () | |
#9 0x346d3f3a in __CFRunLoopRun () |
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
@interface UIImage (ObjColumnist) | |
- (void)updateWithSpecialScaling; | |
@end | |
@implementation UIImage (ObjColumnist) | |
- (void)updateWithAdjustedScaling |
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
Actual API Problems | |
- It raises an exception when you pass in an empty string for sharedInstanceWithToken. This is just a horrible practice. I had previously been using an empty string so that I wouldn't track data from our test server/app. NEVER EVER RAISE AN EXCEPTION. Just NSLog it and return nil if you must. | |
- It raises an exception when calling sharedInstance before sharedInstanceWithToken. NEVER EVER RAISE AN EXCEPTION. Just NSLog it and return nil if you must. | |
- I see no good reason to have a separate object and methods for MixpanelPeople. This seems like some sort of weird name spacing attempt or something like that. This is not done in Objective-C. It is wrong. | |
- set:to: and set: are horrible, horrible method names. Just read the Objective-C coding guidelines by Apple. This is just plain wrong. | |
- The defines like DebugLog need to use an #ifndef. DebugLog is a commonly used thing by developers and you are attempting to redefine it. Be a good citizen and don't do that. | |
Doc Problems |
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
- (IBAction)open:(id)sender | |
{ | |
CATransform3D perspectiveTransform = CATransform3DIdentity; | |
perspectiveTransform.m34 = 1.0f / -2000.0f; | |
CATransform3D endScaleTransform = CATransform3DMakeScale(0.8f, 0.8f, 1.0f); | |
CATransform3D startTransform = perspectiveTransform; | |
CATransform3D endTransform = CATransform3DConcat(endScaleTransform, perspectiveTransform); | |
CATransform3D middleTransform = CATransform3DConcat(CATransform3DMakeRotation(M_PI_4 / 2.0f, 1, 0, 0), endTransform); |
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
- (NSInteger)numberOfSectionsInCollectionView:(PSTCollectionView *)collectionView | |
{ | |
return 1; | |
} | |
- (NSInteger)collectionView:(PSTCollectionView *)collectionView numberOfItemsInSection:(NSInteger)section | |
{ | |
return [_photos count]; | |
} |
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
Suppose I make an app like Instagram. As soon as a photo is taken I upload the original to the server. What's good about this is that it gets it that much closer to being ready to be viewed by others. You can simultaneously allow the user to do other stuff while that's being done. The user now applies and modifies the photo using Core Image filters. When the user finishes instead of uploading a new copy of the modified photo you simply send the information necessary to recreate the effect on the server. Almost instantly that image will be available on the server for others to see. The user won't have to wait for something to upload. You also now have the benefit of having the original photo which maybe you show side by side or allow the user to modify at a later point. | |
This is just one instance off the top of my head. I'm sure there are many more useful things that could be done when interfacing with iOS apps specifically. |
OlderNewer