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
// self.resources is an NSMutableSet of ANResource objects. | |
// I want to remove the objects that have no other references in the app. | |
// (This is intended to be called in response to an iOS memory warning.) | |
// Will this do the trick? | |
- (void)discardUnusedResources { | |
// We pass the objects through a weak reference; if they're not | |
// referenced anywhere else in the app, they won't survive the journey. | |
NSMutableSet * newResources = [NSMutableSet new]; | |
NSUInteger oldResourceCount = self.resources.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
// Note that I have never run this code; it may have bugs or even be syntactically invalid. | |
- (NSAttributedString*)attributedTextForPost:(ANPost*)post { | |
NSMutableAttributedString * attributedText = [[NSMutableAttributedString alloc] initWithString:post.text]; | |
for(ANEntity * entity in post.entities.all) { | |
[attributedText setAttributes:@{ | |
NSForegroundColorAttributeName: [UIColor blueColor], | |
NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle), | |
@"entity": entity |
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
#import <Foundation/Foundation.h> | |
@protocol ADPerformOptionalMethod <NSObject> | |
@optional | |
- (instancetype)performOptionalMethod; | |
- (instancetype)performOptionalMethodOrReturnObject:(id)returnValue; | |
- (instancetype)performOptionalMethodOrReturnValue:(NSValue*)returnValue; |
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
- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)note { | |
if(note.soundName) { | |
[[NSSound soundNamed:note.soundName] play]; | |
} | |
return NO; | |
} |
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
// TsImageSizeConstraintType is an enum with these four values: | |
#define MAP \ | |
ENTRY(TsEditionImageSizeConstraintNone) \ | |
ENTRY(TsEditionImageSizeConstraintDimensions) \ | |
ENTRY(TsEditionImageSizeConstraintPixelCount) \ | |
ENTRY(TsEditionImageSizeConstraintByteCount) | |
NSString * TsStringForImageSizeConstraintType(TsImageSizeConstraintType type) { | |
switch(type) { | |
#define ENTRY(TYPE) case TYPE: return @#TYPE; |
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
// | |
// NSObject+TsPropertyListRepresentation.h | |
// PressKit | |
// | |
// Created by Brent Royal-Gordon on 3/6/13. | |
// Copyright (c) 2013 Novelty Publishers. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> |
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
// | |
// NSSocketPort+initWithLocalhostTCPPort.h | |
// Typesetter | |
// | |
// Created by Brent Royal-Gordon on 4/10/13. | |
// Copyright (c) 2013 Groundbreaking Software. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> |
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
// | |
// TsDistributedNotificationPortNameServer.h | |
// Typesetter | |
// | |
// Created by Brent Royal-Gordon on 4/10/13. | |
// Copyright (c) 2013 Groundbreaking Software. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> |
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
#import <Foundation/Foundation.h> | |
@interface NSNumber (range) | |
- (NSIndexSet*):(NSUInteger)max; | |
- (NSIndexSet*):(NSUInteger)max step:(NSUInteger)step; | |
@end | |
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
#import <Foundation/Foundation.h> | |
@interface NSObject (addVulture) | |
// Do NOT use a block that captures this object. | |
// If you capture it strongly, you'll create a retain cycle. | |
// If you capture it weakly, you'll just get nil. | |
// If you capture it unsafely, you'll start calling methods on a mostly-dealloced object! | |
- (void)addVultureWithBlock:(dispatch_block_t)block; |
OlderNewer