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
Q: What’s wrong with this code? | |
NSLock* arrayLock = GetArrayLock(); | |
NSMutableArray* myArray = GetSharedArray(); | |
id anObject; | |
[arrayLock lock]; | |
anObject = [myArray objectAtIndex:0]; | |
[arrayLock unlock]; |
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
#if __has_attribute(objc_requires_super) | |
#define NS_REQUIRES_SUPER __attribute((objc_requires_super)) | |
#endif |
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
// TestClass.h | |
#import <Foundation/Foundation.h> | |
@protocol TestProtocol <NSObject> | |
@optional | |
- (void) testProtocolMethod; | |
@end | |
@interface TestClass: NSObject | |
{ | |
// Struct that will hold the methods that the delegate implements |
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
#import <objc/runtime.h> | |
#import <objc/message.h> | |
#import <QuartzCore/QuartzCore.h> | |
#define PROPERTY(propName) NSStringFromSelector(@selector(propName)) | |
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it. | |
#ifdef DEBUG | |
static void PSPDFSwizzleMethod(Class c, SEL orig, SEL new) { |
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
" Configuration file for vim | |
" Took some cues from https://github.com/staticshock/dotfiles/blob/master/.vim/vimrc | |
set modeline | |
set modelines=4 | |
autocmd FileType gitcommit,gitrebase setlocal nomodeline | |
" Normally we use vim-extensions. If you want true vi-compatibility | |
" remove change the following statements | |
set nocompatible " Use Vim defaults instead of 100% vi compatibility |
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 p = UILabel() | |
var prompt: NSString? | |
p.text = (prompt != nil) ? prompt! : "This is a prompt question" | |
let enter = UIButton.buttonWithType(UIButtonType.System) as UIButton | |
let bt = (buttonText != nil) ? buttonText : "Enter" | |
enter.setTitle(bt, forState: UIControlState.Normal) | |
var buttonTextColor: UIColor? | |
(buttonTextColor != nil) ? enter.setTitleColor(buttonTextColor, forState: UIControlState.Normal) : {}; |
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
/* Native binding */ | |
extern "C" { | |
void _requestProducts( | |
char** sProductIdentifiers, uint32_t rp_len, | |
ManagedRequestCallback callback) { | |
NSMutableSet* productIdentifiers = [[NSMutableSet alloc] initWithCapacity:20]; | |
for (int i=0; i<rp_len; i++) { | |
[productIdentifiers addObject:GetStringParam(sProductIdentifiers[i])]; |
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
public class MonoPInvokeCallbackAttribute : System.Attribute | |
{ | |
private Type type; | |
public MonoPInvokeCallbackAttribute( Type t ) { type = t; } | |
} |
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
[18:15:43] <Chris> Norrin: it's, like all C declarations, "declaration follows use". | |
[18:16:14] <Chris> So consider char (*x)[42]; You can then reason that *x is a char[42]. And (*x)[3] is a char. | |
[18:16:46] <Chris> Norrin: and in the case of char *x[42]; you can say that x[3] is a char * and *x[3] is a char. | |
so [] has precedence over *. hence why the () are required depending on intention. | |
[18:14:32] <Chris> Norrin: char *(*a)[42]; is a pointer to array of 42 char pointers. |
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
@interface blah : blah | |
-(id)init NS_UNAVAILABLE; | |
@end | |
@implementation | |
-(id)init{abort();} | |
-(instancetype)internalInit { | |
return [super init]; | |
} |
NewerOlder