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> | |
- (NSArray *) getPropertyNamesForClass:(Class)class { | |
NSMutableArray * propertyNames = [NSMutableArray array]; | |
// Fetch Properties | |
unsigned count; | |
objc_property_t *properties = class_copyPropertyList(class, &count); | |
// Parse Out Properties |
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> | |
- (NSArray *) attributesForProperty:(objc_property_t)property { | |
// Get attributes as char | |
const char * attributes = property_getAttributes(property); | |
// Make NSString | |
NSString * attributeString = [NSString stringWithUTF8String:attributes]; | |
// Array of Attributes | |
NSArray * attributesArray = [attributeString componentsSeparatedByString:@","]; |
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
// | |
// NSConcurrentOperation.h | |
// ConcurrencyPractice | |
// | |
// Created by Logan Wright on 5/23/14. | |
// Copyright (c) 2014 Logan Wright. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> |
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
// | |
// NSNonConcurrentOperation.h | |
// ConcurrencyPractice | |
// | |
// Created by Logan Wright on 5/23/14. | |
// Copyright (c) 2014 Logan Wright. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
typedef void (^CompletionBlock)(void); | |
typedef struct { | |
SEL selector; | |
__unsafe_unretained id object; | |
__unsafe_unretained NSArray * arguments; | |
__unsafe_unretained CompletionBlock completionBlock; | |
} ExecutableOperationStruct ; |
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 Cocoa | |
/* To declare a variable in Swift, simply assign something to it, like below: */ | |
var str = "Hello, playground" | |
/* As you can see, there is no explicit type declared. This is because type inference will notice that the variable 'str' is being assigned a string and the compiler will infer that str is of type 'String' */ | |
/* You can declare a Type explicitly using a 'Type Annotation' like this */ |
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 Cocoa | |
// LET vs. VAR | |
/* Up to this point, we have declared all of our names using the keyword `var`. Swift however makes use of another type of variable declaration with the keyword 'let'. At its most basic, `let` indicates that something is constant and `var` indicates that something is variable. */ | |
/* In the following code, we will create a new constant named `someConstant` that will be an unchanging value */ | |
let someConstant = "I am forever constant" |
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 Cocoa | |
/* | |
Basic Function - Let's jump right into it and create an extremely basic function named 'sayHello' that takes no arguments and has no return.*/ | |
func sayHello() { | |
println("Hello!") | |
} |
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 Cocoa | |
/* | |
Up to this point, we've built fairly simple functions that take one or no arguments and return one or no values. | |
Let's first make a basic function that takes two arguments and returns their sum */ | |
func sum(a: Int, b: Int) -> Int { | |
return a + b |
OlderNewer